Solved

Garbage Collection in VB

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

707 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

16 Experts available now in Live!

Get 1:1 Help Now