Memory Overflow Error

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Guest
Memory Overflow Error

Post by Guest » Wed Aug 20, 2003 6:09 am

Hey, this is the first time I have thought of posting on a board like this, so Im new to this side of things, any hints/help would be greatly appreciated,.......

My query is, that I built a program originally in QB1, adapted it to run on QB7, problem is that I am still learning some of the tricks of the new version, and the program I am working on has grown to an extent that when I create EXE, I receive the memory overflow error..

Main question really is... is this error caused mostly by program general size, number of variables using space, or is it possibly a mixture of both? and what can I do to rectify the error so I can compile without losing quality of the program?

Thanks

Dr_Davenstein
QBasic God
Posts:166
Joined:Tue Mar 25, 2003 12:45 am
Location:U.S.A.
Contact:

Re: Memory Overflow Error

Post by Dr_Davenstein » Wed Aug 20, 2003 9:51 am

Add '$DYNAMIC at the top of your code.

You also need to add the /AH option to the QB4.5 command line. It allows dynamic arrays to be larger than 64K each.

If you don't understand, then just look up command line options in the QB help file under contents.


If that does'nt work then you can try SETMEM.
At the beginning of your program...
Dummy&=SETMEM(64000)

At the end of your program...
Dummy&=SETMEM(-64000)

QB help says that a first call to SETMEM trying to increase the far heap will have no effect. It does though, I've used it in all of my larger programs.
It does make a difference if your using large libraries
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!

Guest

Re: Memory Overflow Error

Post by Guest » Thu Aug 21, 2003 5:43 am

okay, thanks Dr, that is much appreciated, I am using Qbasic 7.1, I kinda skipped 4.5 but have it, so if the general opinion is that 4.5 is better pls let me know if I should work that way instead.

User avatar
frankiebaby
Global Moderator
Posts:95
Joined:Tue Apr 30, 2002 1:38 am
Location:Pennsylvania
Contact:

Re: Memory Overflow Error

Post by frankiebaby » Thu Aug 21, 2003 6:21 am

Well, another thing to check, I had a similar problem, is the compiler options. When you hit RUN- make exe, there are two debugging options to turn off. They are on the lower-left. Try turning these off.

Guest

Re: Memory Overflow Error

Post by Guest » Fri Aug 22, 2003 1:40 am

Maybe this is due to the way I have layed out the program code, but I am afraid neither of those worked, I was wondering if sprites would save on memory? as the game is a fruit machine & all the graphics are done in DRAW statements & I have them in a seperate DAT file and load them in to the program on Startup.

I dont have any experience making sprites tho? am I correct in assuming the data are numbers relevant to the colour of each pixel?? & are they fully definable or only able to be made to a specific grid size?

Dr_Davenstein
QBasic God
Posts:166
Joined:Tue Mar 25, 2003 12:45 am
Location:U.S.A.
Contact:

Re: Memory Overflow Error

Post by Dr_Davenstein » Sat Aug 23, 2003 10:54 am

 Actually, I think you should post a sample of what you are doing. There are alot of people that can help more than I can,  but  hey, I'll give it a shot.

;D
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!

Guest

Re: Memory Overflow Error

Post by Guest » Fri Aug 29, 2003 5:59 am

This any help Dr?


FOR p = 1 TO (500 * SpAj(0)): NEXT p
CIRCLE (410, 52), 0, 0: DRAW "A0C4L33G5D12F5R66E5U12H5L33"
CIRCLE (410, 76), 0, 0: DRAW "A0C4L33G5D5F5R66E5U5H5L33"
BonGoin(0) = 0: FOR p = 1 TO 10: FeatFruit(p) = 0: NEXT p
FOR p = 1 TO 4: IF RVal(2, p) < 11 THEN FeatFruit(RVal(2, p)) = FeatFruit(RVal(2, p)) + 1
NEXT p: FeaSet(0) = 1: GDr(0) = 1
IF TrVal(0) > 10 THEN FeaSet(0) = TrVal(0) - 10
IF FeaSet(0) = 2 THEN FeatFruit(10) = 4: FeatFruit(9) = 4
IF WinMark(0) > 3 AND WinMark(0) < 18 THEN FeaSet(0) = 6 - (INT((WinMark(0) - 1) / 3))
TrVal(0) = 0: CashWin(0) = 0
LINE (0, 42)-(370, 200), 0, BF: LINE (0, 95)-(450, 358), 0, BF
LINE (249, 316)-(265, 429), 0, BF
LINE (318, 295)-(446, 352), 3, B: LINE (336, 95)-(428, 295), 3, B
CIRCLE (318, 295), 0, 3: DRAW "C3G2U20E2U13R18L18U7E2U20E2U11R14L14U9E2U20E2U7R10L10U13E2U20E2U5R6L6U15E2U22E4R92"
PAINT (378, 54), 1, 4: CIRCLE (410, 64), 0, 1: DRAW "X" + VARPTR$(FeatFill$(14)): LOCATE 11, 49: PRINT "JACKPOT": Count = 0
FeatStuff$ = &nbsp;_
"M0@3J0@3I0@3P0@3K0@3@2@0G0@3O0@3M0@3H0@3@2@2J0@0K0E0P0@3Q0F0@2@2J0@0@0O0@3@3L0K0@2@2G0@2@0L0@0M0B0K0@2M0K0@2I0I0@0F0O0Q0N0O0P0L0Q0@2K0@0@0D0L0P0A0D0@2K0O0@0H0M0@0K0Q0C0@1E0M0J0J0P0@0E0@1@1F0@1M0H0@2@0@0G0@1H0K0@1G0@1@1@2I0@1@1M0@1J0@1L0@1I0@1"
CIRCLE (410, 52), 0, 0: DRAW "C4L33G5D12F5R66E5U12H5L33": CIRCLE (440, 137), 0, 0: DRAW "A0 X" + VARPTR$(Arra$(0)): CIRCLE (440, 164), 0, 0: DRAW "A0 X" + VARPTR$(Arra$(0)): CIRCLE (440, 191), 0, 0: DRAW "A0 X" + VARPTR$(Arra$(0))
CIRCLE (441, 201), 0, 0: DRAW "A2 X" + VARPTR$(Arra$(0)): CIRCLE (441, 228), 0, 0: DRAW "A2 X" + VARPTR$(Arra$(0)): CIRCLE (441, 255), 0, 0: DRAW "A2 X" + VARPTR$(Arra$(1))
DRAW "A0": CIRCLE (440, 106), 0, 0: DRAW "X" + VARPTR$(FeatFill$(16)): CIRCLE (440, 286), 0, 0: DRAW "X" + VARPTR$(FeatFill$(17)): LOCATE 39, 44: PRINT "HI/LO GAMBLE": CIRCLE (330, 307), 0, 0: DRAW "X" + VARPTR$(FeatFill$(11))
LOCATE 41, 44: PRINT "LOSE": CIRCLE (330, 323), 0, 0: DRAW "X" + VARPTR$(FeatFill$(12)): LOCATE 43, 44: PRINT "SPOT JUMP": CIRCLE (330, 339), 0, 0: DRAW "X" + VARPTR$(FeatFill$(13))
GOSUB FeatDraw: GOSUB FeatLvl: GOSUB FeaCheck
IF FeaSet(0) > 1 THEN FeaSet(0) = FeaSet(0) - 1: GOSUB LevelFull: GOSUB FeatDraw
F1 = VAL(MID$(FlvSt$(FeaSet(0)), 1, 2)): F2 = VAL(MID$(FlvSt$(FeaSet(0)), 3, 2)): CIRCLE (18 + (F1 * 28), 48 + (F2 * 28)), 0: DRAW "A2C14 X" + VARPTR$(FeatBox$(1)): FeatMark = 1
Freshen:
Count = 0: IF CashWin(0) > 0 THEN CGStat = 1 ELSE CGStat = 0
DO: Count = Count + 1
IF In$(0) = "" THEN In$(0) = "PRESS 'START' TO ROLL THE NUMBER!": DoInstruct
IF SBStat(0) = 2 AND CGStat = 0 AND Count > (2000 * SpAj(0)) THEN Count = 0: Flash "LD": SBStat(0) = 1
IF SBStat(0) = 1 AND CGStat = 0 AND Count > (2000 * SpAj(0)) THEN Count = 0: Flash "LF": SBStat(0) = 2
IF SBStat(0) = 2 AND CGStat = 1 AND Count > (2000 * SpAj(0)) THEN Count = 0: Flash "IALD": SBStat(0) = 1
IF SBStat(0) = 1 AND CGStat = 1 AND Count > (2000 * SpAj(0)) THEN Count = 0: Flash "IELF": SBStat(0) = 2
a$ = INKEY$
IF a$ = CHR$(27) THEN SavePlayers: RUN "LOBBY.EXE"
IF a$ = " " THEN Flash "IA": GOSUB NextDice
IF CashWin(0) > 0 AND (a$ = "c" OR a$ = "C") THEN Banked(0) = Banked(0) + CashWin(0): CashWin(0) = 0: GOTO Lost
LOOP

Perhaps you can see how I am working the variables, this is one of the main Subroutines from the program I have had this problem with

User avatar
frankiebaby
Global Moderator
Posts:95
Joined:Tue Apr 30, 2002 1:38 am
Location:Pennsylvania
Contact:

Re: Memory Overflow Error

Post by frankiebaby » Fri Aug 29, 2003 1:17 pm

well, there seem to be quite a few gosubs. Do you use a lot of gosub/return structures, these can eat up a lot of stack space, and may be (part of) your problem. You may want to look at the CLEAR statement, with that, you can set the stack size.

The width of the message board is a bit restrictive when posting code, but some comments would have helped explain what you were doing.

Guest

Re: Memory Overflow Error

Post by Guest » Sat Aug 30, 2003 7:19 pm

Hi, i think i have the same problem.
But i cannot understand, what you said.
I try to print that Dummy& in the beginning, and in the end, it was ok. (I think. But the first dummy& is after the declares.)
I saw the help, and i find that \ah, but i cant understand it.
Please tell me in detail, where can i print that \ah.

Dr_Davenstein
QBasic God
Posts:166
Joined:Tue Mar 25, 2003 12:45 am
Location:U.S.A.
Contact:

Here's a command line sample...

Post by Dr_Davenstein » Sun Aug 31, 2003 3:35 am

C:\QB45\QB.EXE /L QB /AH /MBF

If your running under windows, then just right click on QB, click properties, then program. Look down on the window to where it says Cmd line. That is what you need to modify.

If your running in dos, then all you have to do is type in the command line as shown when you start QB.

BTW: It's simple if you have your QBasic program in the folder C:\QB45. I've always done it that way.

Hey Frankiebaby,
Did you guys ever look at my TankWars game? It's been a few months now. I was just wondering. Here is the URL again in case you forgot! :)

http://www.terraworld.net/davidstanley/ ... UNPACK.exe
;D
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!

Guest

Re: Here's a command line sample...

Post by Guest » Sun Aug 31, 2003 4:29 am

Thanks for the answer, but it still doesn't work. :(

Where can i print the '&DYNAMIC? Into the program, before the declares, right?
If i print this with the apostrof ('), the text stays in little characters. But if i print it without it, it's changed to 0 dynamic. Whitch is the good?

I already try all variations, but not works.

Dr_Davenstein
QBasic God
Posts:166
Joined:Tue Mar 25, 2003 12:45 am
Location:U.S.A.
Contact:

Try this...

Post by Dr_Davenstein » Sun Aug 31, 2003 9:12 am

REM $DYNAMIC
It does'nt matter if it's before the sub declarations or not.

What DIR do you have your copy of QB in?
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!

Guest

Re: Try this...

Post by Guest » Sun Aug 31, 2003 1:27 pm

Still not works.

My qb45 is in c:\qb45.
The .bas file is in this, too.

My program is 239 kb.
The error message is:

Out of memory

43245 bytes available
0 bytes free
0 warning error
1 severe error

Guest

Re: Try this...

Post by Guest » Sun Aug 31, 2003 1:30 pm

Well...

I have an idea...

What if i try to send you this file?

Could you solve the problem?

It's a strategy game, from the world of fallout.
Very cool...

Composer
Newbie
Posts:3
Joined:Thu Aug 21, 2003 6:04 am

Re: Memory Overflow Error

Post by Composer » Sun Aug 31, 2003 6:03 pm

hey evry1

I managed to solve my memory overflow problem by adjusting some of the code, so it works for now, im fine with that, I was looking at using the '$include 'future.bi' as I am using QB7.1, and all the include does as add sub and function declarations to my program, i.e. "declare sub MouseShow ()" but I dont actually get the subroutine, and none of the library functions actually work without the code, so am I missing something or am I doing something wrong here??

Post Reply