2012-02-13 6 views
1

私たちの自動化された環境でこのクラスが大量に漏洩していることに気づいています。私はこの問題について検索しようとしましたが、利用可能な情報が見つかっていません。MS.Win32.HwndSubclassのメモリリーク

ANTSは、これらのインスタンスはすべてGCルートオブジェクトであると言います。

私の知る限り、HwndSubclassはWindowsFormsHostで使用されています。ただし、この特定のシナリオでは、WindowsFormsHostは使用されません。これは、WindowsFormsHostのインスタンスについての知識がないANTSによって確認されています。

HwndSubclassがどのような状況で使用されているのですが、どのように正しく削除されるようにするにはどうすればよいですか?

EDIT: Win7(x64)の環境はWPF4(x86)です。

答えて

2

「設計上」のように見えます。

HwndSubclassコード内のコメントから:

// Allocate a GC handle so that we won't be collected, even if all 
// references to us get released. This is because a component outside 
// of the managed code (ie. the window we are subclassing) still holds 
// a reference to us - just not a reference that the GC recognizes. 

、その後

// This is LIVE OBJECT because it has a GCHandle. The only time LIVE OBJECTS 
// are destroyed is during Shutdown. But Shutdown cleanup is handled through 
// the ManagedWndProcTracker and hence no work needs to happen here. PLEASE 
// NOTE that reintroducing any cleanup logic in here will conflict with the cleanup 
// logic in ManagedWndProcTracker and hence must be avoided. If this instance 
// has been disposed its GCHandle is released at the time and hence this object 
// is available for GC thereafter. Even in that case since all the cleanup has been 
// done during dispose there is no further cleanup required.