Solved

Garbage Collection in VB

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now