In one of my VB6 forms, I create several other Form objects and store them in member variables.
Private m_frm1 as MyForm
Private m_frm2 as MyForm
// Later...
Set m_frm1 = New MyForm
Set m_frm2 = New MyForm
I notice that I'm leaking memory whenever this (parent) form is created and destroyed. Is it necessary for me to assign these member variables to Nothing
in Form_Unload()
?
In general, when is that required?
SOLVED: This particular memory leak was fixed when I did an Unload
on the forms in question, not when I set the form to Nothing
. I managed to remove a few other memory leaks by explicitly setting some instances of Class Modules to Nothing
, as well.