Link to home
Start Free TrialLog in
Avatar of nasia
nasia

asked on

Freeing Resources

I have a program that is running infinitely, it sleeps for 15secs and then restart again (using sleep function), the problem is after hours of running, the memory that it uses increases. i.e. when it starts it uses 4K of memory for after about 8 hours the memory used is like 150MB. what can i do, the program basically opens databases in SQL and does some computations to it.
Avatar of zabman
zabman
Flag of United States of America image

I wasn't Aware that VB had a sleep function, but . . . .

It sounds like you could have a few problems, i'd need more info to be sure, but check for these:

1.  Memory Leak:  If your program is loading and unloading itself, be sure to use the UNLOAD (form) function.  Also could occur when you open/close the database.

2.  Program Storage:  If you are using arrays and don't need the data for other computations, be sure your clearing out the old data, or data you don't need.

that's about it for me.  Basically, look for any place in which the program is not shutting down correctly, OR that you are emptying out your program storage.

                                   -- Zabman :-)
ASKER CERTIFIED SOLUTION
Avatar of manoj_r
manoj_r

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nasia
nasia

ASKER

isn't set object = nothing same as object.close.... if not does this mean i have to put a set object = nothing to all recordsets after i close it, even if its not a global variable???
You will be better off doing that, yes. To summarise

1 If any of your object variables (recordsets, for example) have a "close" or similar method, execute it.
2 Unload all forms and any controls loaded in code
3 Set all object variables to Nothing


Avatar of nasia

ASKER

its hard work... i've set all my recordset/database variable to nothing... i dont use any forms so theres no problem there... i'll observe my prog bahavior...
Make sure you are also setting the database connection to nothing unless you are absolutely certain you are not opening a database connection (login) every time you go to the database.  DB connections, more so than the recordsets can chew up memory because they drag in alot of overhead with them.