Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Freeing Resources

Posted on 1999-07-11
Medium Priority
Last Modified: 2011-04-14
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.
Question by:nasia
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 1523599
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 :-)

Accepted Solution

manoj_r earned 100 total points
ID: 1523600
You can free up the objects you use by using the Nothing statement.

Set Form = Nothing
Set recordsets = Nothing
Set database = Nothing

and so on

This will explicitly free up the resources used by the objects.

Author Comment

ID: 1523601
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???
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 10

Expert Comment

ID: 1523602
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


Author Comment

ID: 1523603
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...

Expert Comment

ID: 1523604
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.


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

662 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question