MEMORY OVERFLOW ERROR !!! (Don't need help anymore)

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
TmEE
Veteran
Posts: 97
Joined: Mon Mar 17, 2008 11:14 am
Location: Estonia, Rapla
Contact:

MEMORY OVERFLOW ERROR !!! (Don't need help anymore)

Post by TmEE »

I've got them before actually, but managed to get rid of them by moving some code to SUBs (I think I hit the 64k code per SUB limit).
Now I got it again, so I moved more code to SUBs, and the error remains... I can run it in IDE, but not compile...

Source file is 68.6KB big, consists of almost 3000 lines of code, lots logic operations and direct I/O...

any ideas ?
Last edited by TmEE on Mon May 26, 2008 12:29 pm, edited 1 time in total.
Mida sa loed ? Nagunii aru ei saa :P
User avatar
Mentat
Veteran
Posts: 409
Joined: Tue Aug 07, 2007 3:39 pm
Location: NC, US

Post by Mentat »

Try to keep data in separate files and the processes to the executable itself.

If you are in real need of compression, with some fancy tricks, you can save multiple flags to a variable.
For any grievances posted above, I blame whoever is in charge . . .
TmEE
Veteran
Posts: 97
Joined: Mon Mar 17, 2008 11:14 am
Location: Estonia, Rapla
Contact:

Post by TmEE »

I have nearly no data in the file, its all code... there's not much variables either... maybe half a KB. There's array's, but they all are less than 5...6KB. I also use 512KB of XMS but that doesn't matter...

I think I'm having too much code...

Code: Select all

COMMON SHARED HANDLE%, MBASE%, speed%, SCOUNT%, QUIT%, TMFROW%, ORDERROW%
COMMON SHARED TMFLEN%, TMFPAT%, EXITS%, PAGE%, MX%, MY%, MB%, COCTAVE%
COMMON SHARED KEYS%, TRACKPOS%, SAC%, PLAYMOD%, SEGM%, OFFSET&, OFFSET2&
COMMON SHARED Title$, Author$, Notes$, TMFdate$, CURPOS%, LASTCUR%, Ch1%
COMMON SHARED NOOT%, OKTAV%, OCTPLUS%, NOTE%, octave%, EFFECT%, VALUE%
COMMON SHARED EDITCH%, LCPOS%, CPOS%, DRUM%, i%, L%, C%, C2%, START%, ISPEED%
COMMON SHARED OFFS%, XOFF&, BYTES&, ERRR%, LASTCUR2%, CURPOS2%, EDITPOS%
COMMON SHARED ZSEG%, XSEG%, CDIR$, TMFfileName$, UPDATEPOS%, COPYSTART%
COMMON SHARED COPYLEN%, SHIFTON%, COPYCH%, COPYS%, COPYPASTELEN%, ERR2%
COMMON SHARED PLAYINLOOP%, LOOPVAL%, CHAN%, CTRL%, PATCH%, SPD%, DIR%
COMMON SHARED SHIFTSTART%, SHIFTEND%, LOOPORDER%, ECH%, EDITENABLE%, OFFSETP&

DIM SHARED Patterns&(63, 7)    'Current pattern, rest is in XMS
DIM SHARED OrderTable%(255, 6) 'Order table
DIM SHARED CopyPaste&(63)      'CopyPaste buffer
DIM SHARED Transpose&(63)      'Transposing buffer
DIM SHARED Patches%(8)         'Current instruments
DIM SHARED NoteVols%(8)        'Current volumes
DIM SHARED NotePans%(8)        'Current pan positions
DIM SHARED NoteRevs%(4)        'Current reverb amounts
DIM SHARED SPatches%(4)        'Start-up instruments
DIM SHARED SNoteVols%(8)       'Start-up volumes
DIM SHARED SNotePans%(4)       'Start-up pan positions
DIM SHARED SNoteRevs%(4)       'Start-up reverb amounts
DIM SHARED Instrument$(127)    'Instrument names
DIM SHARED Notes$(13)          'All notes that get displayed
DIM SHARED LastNote%(10)       'Last note played (for MIDI KEY OFF)
DIM SHARED HEXnum$(255)        'Hex numbers
DIM SHARED NumPt%(6)           'Number of patterns on each channel
DIM SHARED PSGnotes$(127)      'All PSG track notes
DIM SHARED PSGfreqs%(127)      'All PSG frequencies
DIM SHARED PSGvols$(16)        'All PSG volumes
DIM SHARED ChMutes%(8)         'Mute flags of all channels
DIM SHARED SlideCount%(4)      'Slide increment/decrement
DIM SHARED SlideFrame%(4)      'Slide frame count
DIM SHARED SlideFrames%(4)     'Slide frame counter
DIM SHARED SlidingDir%(4)      'Slide direction
DIM SHARED RandomPan%(4)       'Random panning
DIM SHARED DrumKeys%(127)      'Drum scancode to instrument table
And some bytes of data as DATA statements...
Mida sa loed ? Nagunii aru ei saa :P
User avatar
Mentat
Veteran
Posts: 409
Joined: Tue Aug 07, 2007 3:39 pm
Location: NC, US

Post by Mentat »

That's a lot of DIM SHAREDs. A lot. Are you passing values through subroutines by reference?
For any grievances posted above, I blame whoever is in charge . . .
TmEE
Veteran
Posts: 97
Joined: Mon Mar 17, 2008 11:14 am
Location: Estonia, Rapla
Contact:

Post by TmEE »

Routines need full access to the arrays/variables
Mida sa loed ? Nagunii aru ei saa :P
Ralph
Veteran
Posts: 148
Joined: Fri Feb 09, 2007 3:10 pm
Location: Katy, Texas

Post by Ralph »

The url below deals with "Program memory overflow" in qbx (PDS), as due to too many constants )over 680). Perhaps that is your problem?
http://support.microsoft.com/kb/61349

Also, this question is answered here:
http://www.outer-court.com/basic/echo/T37.HTM

In the second case, the error message refers to the program size in the interpreter as being under the 64K limit, but being too large for the object file. The solution is given in the second url, as to make two, smaller object files.
Ralph, with QuickBASIC 4.5, operating under Windows XP, wiht anHP LaserJet 4L Printer. Bilingual in English/Spanish
TmEE
Veteran
Posts: 97
Joined: Mon Mar 17, 2008 11:14 am
Location: Estonia, Rapla
Contact:

Post by TmEE »

I have the second issue then... can't fit stuff to OBJs...

Now I need the command line switches and stuff of BC.EXE and LINK.EXE...
Mida sa loed ? Nagunii aru ei saa :P
Ralph
Veteran
Posts: 148
Joined: Fri Feb 09, 2007 3:10 pm
Location: Katy, Texas

Post by Ralph »

Exploring farther:

My QuickBASIC 4.5 Help/Modules/Modules and Procedures says that there can only be one main module, or "the main program". So, it would seem to me that you need to farther reduce your code, anyway you can, before you can create your object and compiled files.
Ralph, with QuickBASIC 4.5, operating under Windows XP, wiht anHP LaserJet 4L Printer. Bilingual in English/Spanish
TmEE
Veteran
Posts: 97
Joined: Mon Mar 17, 2008 11:14 am
Location: Estonia, Rapla
Contact:

Post by TmEE »

There is NO way to reduce the code... its already hyper space and speed optimized...

it seems I need to start digging FreeBASIC... any recommendations on getting started ?
Mida sa loed ? Nagunii aru ei saa :P
BDZ
Coder
Posts: 49
Joined: Sun Nov 20, 2005 5:41 pm
Location: Wisconsin
Contact:

Post by BDZ »

You don't need to start digging Freebasic. I would've posted in this topic earlier, but I figured someone would come along who could explain it better than me.

There is a 64k limit per module, so you need to split your program into 2 or more modules, compile them into object files seperately, then link them together. This sounds daunting, but I did it with my game awhile back and it wasn't too hard. The GUI makes it really easy to treat multiple modules like one. You can also have it so it automatically loads them in at the same time, and when you compile it links them for you. I don't have the time right now to explain exactly how you should do this, but this is the way to go.
TmEE
Veteran
Posts: 97
Joined: Mon Mar 17, 2008 11:14 am
Location: Estonia, Rapla
Contact:

Post by TmEE »

the thing is the main module doesn't even have 200 lines of code... and no other part exceeds the 64K limit, at least none has enough code to exceed it...

And I need to make a Windows version of my tracker anyway, so FB is the best option for that... first a pmode DOS version, then a Win version...
Mida sa loed ? Nagunii aru ei saa :P
Yazar
Coder
Posts: 11
Joined: Sat May 24, 2008 10:51 pm

Post by Yazar »

just divide your code into more modules. To do this, Open file menu, create file, and move your subs to there...
TmEE
Veteran
Posts: 97
Joined: Mon Mar 17, 2008 11:14 am
Location: Estonia, Rapla
Contact:

Post by TmEE »

well, it won't work... and I already have FB version in progress... damn MIDI, I've not got it to work in Win yet... I'll go for YM2612 emulation directly.
Mida sa loed ? Nagunii aru ei saa :P
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

?????????

Post by burger2227 »

Why ask for advise and TOTALLY ignore it?

Some kind of genius or just plain stubborn?
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
TmEE
Veteran
Posts: 97
Joined: Mon Mar 17, 2008 11:14 am
Location: Estonia, Rapla
Contact:

Post by TmEE »

because it does not work, i still get the error. I can have all the 3000 lines of the program in 3000 separate files and still get the error.
Mida sa loed ? Nagunii aru ei saa :P
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

What are you considering?

Post by burger2227 »

Many QB programs will compile at 64K, but not ones that use so many SHARED variables. Why not try to place the arrays into the SUB call parameters?

QB 7 or PDS have some peculiarities also. Did you read the M$ recommendations?

Your code is 3000 lines? Then you are using a lot of code memory also. You could try CHAIN and make a data file to transfer the COMMON SHARED variables if you want a stand alone EXE. COMMON SHARED does not work in Stand alone linked EXE programs.

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
TmEE
Veteran
Posts: 97
Joined: Mon Mar 17, 2008 11:14 am
Location: Estonia, Rapla
Contact:

Post by TmEE »

I've read all M$ recommendations and such... no workaround. If I'd use CHAIN, then it would things be called many many times a second and it would kill all performance.
Also, there's about 1000 lines of ASM in a form of library used in the program...

Anyway, I AM working on a FreeBASIC version, making a Windows port of this program... and its required too as I want this tracker to be the best music tool for Sega Mega Drive / Genesis and for that I need to incorporate several more thousand lines of code (there's some custom sound chip emulation required) and it would just be tooooo big pain to do in QB on its own...
Mida sa loed ? Nagunii aru ei saa :P
Post Reply