Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with OUT OF MEMORY 1

Status
Not open for further replies.

Corbinealious

Technical User
Aug 24, 2007
13
for those of you who want to jump straight into the question, basically...

i'm looking for a programming environment thats essentially just like qbasic but can compile using more memory.

for the longer explanation... ive been writing a game in Qbasic (4.5) and ive reached a point where i cant add anything without getting a "OUT OF MEMORY" error when i compile. so what next?

as for what ive done so far, i tried downloading some other compilers. i was hoping visual basic was similar, but its not... i tried a compiler called rapidQ, but i didnt understand it at all (although i cant say i spent much time there...) and i tried freebasic, which claims to be just like Qbasic, but i couldnt even get to the command prompt for it. after installing it and running the shortcut it puts on my desktop it only opens a dos command prompt, and i tried running every .exe in the folder and they all seem to do nothing.

basically i just want to be able to finish this little project of mine without having to learn a whole new programming language. i dont understand much about compilers im finding, but i just want something that can run my code. which id love to link for you if you're interested! but there doesnt seem to be an attachment option...

anyway any help would be appreciated! thanks in advance!
 
Search the web for microsoft professional development system 7.1 It may help with your memory problem.
 
The second link I gave you may not be complete and it contain no subdirectories, so it may or may not work.

As far as the install you tried, I ran it, got the same error you did, then just ran setup again and it ran to completion...
 
ok so i can run vbs7.1. but apparently by default it allocates less memory than qb4.5.

ive been able to continue my game because i realized i was reserving way more memory than needed (every graphic i reserved 280 when i could get by with 256, etc...) so i lowered some numbers. but i realize this is only a temporary fix, and ill probably run out again.

vbs7.1 talks about tapping into extended or expanded memory though, and i tried reading the help files like 4 times and doing what they said, but i guess i dont understand it.

for example, in the expanded memory help it says if i run the program by typing QBX /e:500 /EN it should reserve 500k extra for me. but it just didnt recognize the command. any suggestions?

and thanks for your help so far!

(side note: the help sections im referring to are in contents->Qbx memory and capacity)
 
aha! wow i cant believe i did that... well so now it runs the program, but i still run out of memory at the same point. i even tried doing 20000 instead of 500. do i have to tell my program to allocate the variables im dim-ing into the expanded memory? and if so, how?
 
If you invoke QBX without the /e: switch, QBX will use all available expanded memory. Try starting QBX without any parameters then enter and run:

? fre(-3)

The value returned will be remaining space in expanded memory (in kilobytes). The following is from the help file on Using Expanded Memory.

If expanded memory is available to QBX, it automatically moves all units of program code between 512 bytes and 16K in size, inclusive, out of conventional memory into expanded memory. Each procedure (function or sub) is a unit of code. The module-level code also constitutes a unit of code.

To see how large each procedure is, use the View Subs ommand (press F2). You can determine which units are larger than 16K and need to be divided into smaller units.

but i still run out of memory at the same point.
What is the statement where you run out of memory and is this a run-time error or while editing?
 
alright, so i run qbx and then just essentially write a program that only contains one line saying "? fre(-3)" and execute it? if so, it turns the "?" to "PRINT", and tells me "Feature unavailable". if there's somewhere else im supposed to run it from i dunno where it is. (well, i hit f6 and ran it down there too, it leaves the ? as a ? but gives the same error haha.)

i noticed the bit about moving things 16k-512k... all my subs are 11 or less (but i have 36 subs that all do various seperate tasks...) so its not moving them into expanded memory right? anyway i can tell it to move things 6k and up or something?...

i use a lot of variables, and right now the out of memory error highlights one of the arrays close to the end of all my DIM SHARED statements at the beginning
 
hey! ok so as mentioned before i found i was allocating more memory than i needed, and by cutting down ive been able to continue but i know it wont last forever.. anyway ive been continuing in qb4.5. and i tried the ? fre(-3) command there and it works. my program has about 26k left. for kicks i decided to find the biggest array i could define before it hates me, and Bob(4423) works. but Bob(4424) runs me out of memory in the code somewhere. if im conservative i might be able to finish within that amount... but id like to figure out how to get around this anyway haha. also, with bob(4423) the ?-fre(-3) command still returns 13k. can i not use that memory?
 
do you have several bas programs that are linked with a mak file or is everything in one bas file (i dont recall seeing if you said one way or the other). If it is all in one bas
file, try splitting it up butting some of the subs in separate bas files with no executible code then use the load option (first time) to load all the bas files. then when you compile, it will compile each separately then link them together allowing larger programs. That may help.
 
Apparently your system is not providing any expanded memory to QBX. From QBX FRE Details:

Using FRE(-3) and Expanded Memory
o If expanded memory is not available, FRE(-3) returns the message "Feature unavailable."

What operating system are you using? By default, XP's command prompt is giving me 4MB of expanded memory.

FRE(-3) in QB 4.5 returns a different value, "The size of the next free block of string storage"

What type of variable does array Bob() contain?

And be sure to read Buff1's post.
 
ah... yeah with vbs7.1 i guess i dont have expanded memory available. should i try the extended memory route? i dont really know what the difference is.

oh and by the way im running XP as well. the bob() array was just whatever the default value is, which i believe is int? i didnt set a standard manually...

in response to buff1, your solution sounds like it should help, but i dont seem to fully understand how to do it. for example, i wrote 2 programs. one called loadtes1.bas which simply contained (brackets not really there :p
{dim shared a
a = 3
printA
print "in the main program, a =";a}
and then i made a second program called loadtes2.bas. which had nothing but a sub called printA which had
{print "in the sub a =";a}
i opened loadtes1.bas and used load to add loadtes2.bas as a module. and when i ran the program i got
"in the sub a = 0
in the main program, a = 3"
so i know its accessing the sub, but apparently its not passing the variable a to the second program. can i make a shared through everything? or will i have to pass the variables im using into the sub every time? cuz my subs often check various arrays of 8 players worth of data, which would be a pain to pass into the subs :(

thanks everyone helping btw!

 
Still blowing off the dust as I haven't programmed in QuickBasic for about 10 years so bear with me :)

First, do yuo want to continue using 4.5 or try to get PDS 7.1 going?

Next, the default variable used by QuickBasic is single-precision, which requires 4 bytes. If you don't require floating-point and no value exceeds 32767 or is less than -32768, than a DEFINT A-Z at the beginning of your program may gain you more space as integers occupy only 2 bytes.

In order to share variables between modules, you will need to use a COMMON statement in each module listing the variables you wish to share.

 
so i tried DEFINT A-Z and for some reason it tells me one of my arrays isnt defined. i define it at the beggining as
DIM SHARED temphand(12)
nothing special. i tried initializing it again and it flags it as a duplicate definition, so it should be registering it, i have no idea why defint a-z would be making it not work.

aha! thanks for the load tip, apparentl i need COMMON SHARED for every variable! ill try breaking up some pieces and see how it goes...

well heres a question i just though of. so say i split the program into 2 bas files. some of the memory be allocated for one bas and one for the other? or will it just double my memory pool? cuz if i start every bas with COMMON SHARED how will it know which .bas to allocate the memory too?
 
oh! and im quite content continuing in qb4.5. the only problem ive ever had with it is this stupid memory thing. id make this in c++ or java but i dont know how to work with graphics in those haha... but im taking classes!
 
Place the DEFINT A-Z at the beginning of your program, prior to any DIM statements.

THe following will look daunting, but try to read through it. It has many good points about program modules, COMMON, COMMON SHARED, SHARED, DIM SHARED, $DYNAMIC and $STATIC Arrays,huge arrays, and sample programs.
 
ok... a few things. i read through the whole help file, and it all sounded exciting, but either im not really understanding it and im using it wrong, or i just dont understand my real problem at all.

so with defint a-z. as mentioned it causes at least one of my arrays to supposedly be not defined. i was putting defint a-z right after all my declare subs, screen 13, and randomize timer, and right before all my DIM SHARED statements. i tried putting defint a-z as my very first line of code, and it then tells me there is a parameter type mismatch for m subs which have variables passed into them. i declare them "DECLARE SUB a(b,c)" basically, but with more useful names. no idea whats wrong there.

i tried the rem $dynamic statement. which to my understanding should make all my arrays dynamic and thus store them in far memory (limit 640k as opposed to 64k) but then i tried testing how much space i had with my bob() array and it still has a near limit.

i loaded my bas in vbs which shows how big my subs are, and without counting subs that are only 1k i counted 72k (its pobably rounding up a lot...) and my understanding is the code amount caps at 64k per bas. so i probably need to split the code up. i started trying that, but either you cant have common 2 dimensional arrays, or you have to define them diferently. but when i say
common shared playerspick(5,8)
it expects a ) after the 5

any ideas on any of the 3 said problems?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top