'sometimes' hang while disposing a form which contains an ActiveX
control (Flash.ocx version 7). The form's Dispose() method generated by
the form designer
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}
However, it never puts anything in 'components'. Anyway, the hang is
inside the base.Dispose
mscorlib.dll!Sy stem.GC.GetTota lMemory(bool forceFullCollec tion = true) + 0x23 bytes
system.windows. forms.dll!Syste m.Windows.Forms .Application.Co llectAllGarbage ()
+ 0xd bytes
system.windows. forms.dll!Syste m.Windows.Forms .AxHost.Release AxControl()
+ 0x2a6 bytes
system.windows. forms.dll!Syste m.Windows.Forms .AxHost.Transit ionDownTo(int
state = 0) + 0x151 bytes
system.windows. forms.dll!Syste m.Windows.Forms .AxHost.Dispose AxControls()
+ 0x30 bytes
system.windows. forms.dll!Syste m.Windows.Forms .Control.Dispos eAxControls()
+ 0x54 bytes
system.windows. forms.dll!Syste m.Windows.Forms .Control.Dispos e(bool
disposing = true) + 0x1ce bytes
system.windows. forms.dll!Syste m.Windows.Forms .ContainerContr ol.Dispose(bool
disposing = true) + 0x2b bytes
system.windows. forms.dll!Syste m.Windows.Forms .Form.Dispose(b ool
disposing = true) + 0x2b0 bytes
TestDisposeAx.e xe!TestDisposeA x.Form2.Dispose (bool disposing = true)
Line 48 C#
The stack trace leaves me with several questions.
1. GetTotalMemory( true). One reference says this will call garbage
collection repeatedly until memory usage stabilizes within 5% - which
sounds like it blocks some indefinite period of time. Other references
say this just means it might wait 'a short time'.
2. Why would ReleaseAxContro l call CollectAllGarba ge??
3. Why, after I try Controls.Remove (player), does that base.Dispose()
still wind up down in ReleaseAxContro l?
4. And of course, what could be blocking that GetTotalMemory? All other
threads which I can see are merely waiting for an event. The form and
the player were created on that main thread, the same one making the
dispose call. I'm not aware that we've coded any of our own finalizers
anywhere.
It doesn't always hang. I do have a repeatable way to get my whole app
to hang, and a repeatable way where it doesn't hang, but at the point
of the call to dispose they aren't any different! My only guess as to
why that would happen is that one way churns more memory than the
other, maybe forces more garbage collections or something.
For reference, we are stuck back on 1.1 and I have little hope of being
able to change that any time soon.
Any suggestions?