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!

How do I erase variables?

Status
Not open for further replies.

Sandmann

Programmer
Mar 12, 2001
13
US
I have a program that I've written that uses lots and lots of variables. There are literally hundreds of them. How do I get rid of them while the program is running so that I can free up the space and not run out of memory? I know that with arrays there is the ERASE command but it doesn't work with regular variables. Any help would be great. Thanks.
 
Another thing about this. This program I've made works find on my computer, but when my friend uses it on his, it works fine too, but once it gets to a certain point, it crashes and says, "OUT OF MEMORY" Usually this is due to the program being to big, but if that were so, wouldn't it crash when the program is first run? I figure it's the amount of variables used becuase it crashes at a point when a large amount of new variables are introduced.
 
Can you post your code so we could advise you better? If it's really that big, you could email me at miggyd2000@ yahoo.com . I've got some time before my new classes startup and could take a look at it for you.

--MiggyD

 
One thing you might look at is how many of your variables are actually shared among the various modules or reused through repeated calls to the subs or functions.

I have always found it a good practice to use the ERASE command (as you noted), place most related variables in an array and then REDIM them with zero elements when finished with them... even changing string variables to "null" length after using them for the last time, eg. [tt]A$ = ""[/tt]
VCA.gif

Alt255@Vorpalcom.Intranets.com
 
Good point Alt255, if you have an integer variable, that is constantly being modified then why not use the same variable as a counter or point (temporarily of course) like in a FOR/NEXT or something.

However, if Sandmann is returning to the beginning of the program (EX: RUN 10 OR RUN OR whatever) and has DIMs (that after the initial run) have been REDIM'd lower, that in itself may be the cause of his problem.

Sandmann, again, I say, post your code if at all possible.

--MiggyD
 
Thanks for all the help. I haven't taken the time to put everything into arrays yet (there are a lot of variables) but MIGGYD, if you still would like to look at my code, I can send it to you.
Thanks. :)

Sorry it took me so long to get back on this, my computer died.
 
Go ahead and mail me. I'll see what I can do.
--MiggyD "The world shrinks more and more with every new user online."
 
How about ordering your variables so they are only pulled when they are needed. Within different sections of your code you can reuse variable names so long as you keep track of where and when they are loaded.
Without knowing the code it is hard to make alternate suggestions. Ed Fair
efair@atlnet.com

Any advice I give is my best judgement based on my interpretation of the facts you supply.

Help increase my knowledge by providing some feedback, good or bad, on any advice I have given.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top