Click to See Complete Forum and Search --> : Unloading Forms


Gordito
November 1st, 1998, 06:52 AM
I've noticed with VB that you can unload a form, for example, MyForm.Unload, and the form, MyForm does not really unload from memory. Is there any other way to unload or destroy the Form object in VB.


Gordito

Justin Decker
November 1st, 1998, 10:19 PM
When you unload a form, it removes it from memory, when you hide a form, it is still in memory just not visible.

Gordito
November 7th, 1998, 06:07 PM
In theory, you are correct Justin, but that was not my question. I know unload is supposed to unload a form from memory ... but from my experience it does not completely take the form out of memory. Has anyone else noticed this behavior?


Gordito

Justin Decker
November 7th, 1998, 08:12 PM
Why do you think that unloading a form does not take it out of memory?

DragonDigital
November 10th, 1998, 05:11 AM
I'm sure last time I looked at this, I found that the unload command does not always unload them from memory, or at least the memory is not reclaimed. I had some very large forms, and I examined the memory usuage of the application before, during and after using the form. It did not drop when the form was 'unloaded'. Somebody explained to me, that it's a trick of VB so that it does not have to reload the form if you want to show it again. The system only unloads them proper if it's running low on memory or you explicietly tell it to unload (I forget how)

Crazy D
November 11th, 1998, 02:21 AM
There's an API call something like KillWindow. This will free it definitely (and you can't call it again in your app).

But, you'll probably not notice it, but lots of programs doesnot free memory when forms are unloaded. Indeed, VB does some memory tricks, but I think not only VB does that... I found out that Borland C++ Builder does the same trick sometimes. And besides that, Windows does not always free the memory directly.