Hang in Dispose with ActiveX control

J

Jeff

Banging my head against the wall trying to figure this out. I have a
'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.Dispose();
}
}
base.Dispose( disposing );
}

However, it never puts anything in 'components'. Anyway, the hang is
inside the base.Dispose
mscorlib.dll!System.GC.GetTotalMemory(bool forceFullCollection = true) + 0x23 bytes

system.windows.forms.dll!System.Windows.Forms.Application.CollectAllGarbage()
+ 0xd bytes

system.windows.forms.dll!System.Windows.Forms.AxHost.ReleaseAxControl()
+ 0x2a6 bytes

system.windows.forms.dll!System.Windows.Forms.AxHost.TransitionDownTo(int
state = 0) + 0x151 bytes

system.windows.forms.dll!System.Windows.Forms.AxHost.DisposeAxControls()
+ 0x30 bytes

system.windows.forms.dll!System.Windows.Forms.Control.DisposeAxControls()
+ 0x54 bytes
system.windows.forms.dll!System.Windows.Forms.Control.Dispose(bool
disposing = true) + 0x1ce bytes

system.windows.forms.dll!System.Windows.Forms.ContainerControl.Dispose(bool
disposing = true) + 0x2b bytes
system.windows.forms.dll!System.Windows.Forms.Form.Dispose(bool
disposing = true) + 0x2b0 bytes
TestDisposeAx.exe!TestDisposeAx.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 ReleaseAxControl call CollectAllGarbage??
3. Why, after I try Controls.Remove(player), does that base.Dispose()
still wind up down in ReleaseAxControl?
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top