Solved

Garbage Collection in VB

Posted on 2003-11-17
5
525 Views
Last Modified: 2010-05-18
Being in a proccess of lowering the overall memory usage of our application, I have built many tester applications to pin point specific problems regarding memory.

In one of the testers I defined a form, created it and then closed it.... The application's memory has raised, but never lowered...
When I showed that form again, the memory stood still.

Why doesn't VB free up the memory of a form I unloaded, and set to Nothing ?
0
Comment
Question by:UriS
[X]
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
  • 3
5 Comments
 
LVL 7

Accepted Solution

by:
Z_Beeblebrox earned 50 total points
ID: 9766829
There are lots of possible reasons. One possible reason is that it is a performance optimization, because releasing (and then possibly reaquiring) memory can be an expensive operation, so if only a small amount of memory is no longer used, it is better just to hang on to it in case it is needed later. Also, VB is quite memory intensive, so unless you are talking tens of megabytes of difference, there probably is not a problem.

Zaphod.
0
 
LVL 7

Expert Comment

by:Enlade
ID: 9767196

Maybe you are not unloading the form when you say that you "Closed" it.  If you do not unload the form then it will remain resident in memory.  Did you do something like this in the exit of the form?

Unload Me

If not then maybe that is what is wrong.
0
 
LVL 2

Author Comment

by:UriS
ID: 9767372
I do unload the form...
dim f as SomeForm

set f = new SomeForm
f.show vbModal
set f = nothing <-- I get here when the form unloads..


0
 
LVL 7

Expert Comment

by:Enlade
ID: 9767476

Just for my sake try:

Unload f

0
 
LVL 7

Expert Comment

by:Enlade
ID: 9767490

For instance,

set f = new SomeForm
f.show vbModal, Me
Unload f
Set f = nothing

It probably won't matter, but just to be sure.
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

734 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