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
Printable View
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
When you unload a form, it removes it from memory, when you hide a form, it is still in memory just not visible.
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
Why do you think that unloading a form does not take it out of memory?
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)
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.