Solved

Garbage Collection in VB

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

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…
Suggested Courses
Course of the Month5 days, 18 hours left to enroll

627 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