Solved

Garbage Collection in VB

Posted on 2003-11-17
5
523 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
  • 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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

770 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