Search

3/30/2008

as simple as possible, but no simpler: Drip: IE Leak Detector

as simple as possible, but no simpler: Drip: IE Leak Detector

How it Works

Fortunately, Internet Explorer's architecture made this app fairly easy to build. It's basically a simple MFC app with a browser COM component in it. The strategy for catching leaked elements is as follows:


* When a document has been downloaded, sneakily override the document.createElement() function so that the application is notified of all dynamically-created elements.

* When the document is fully loaded, snag a reference to all static HTML elements.

* To detect leaks: navigate to a blank HTML page (so that IE attempts to release all of the document's elements),

* force a garbage-collection pass (by calling window.CollectGarbage()),

* and look at each element to see if it has any outstanding references (by calling AddRef() and Release() in succession on it).

Within the leak dialog, each element's attributes are discovered and enumerated using the appropriate IDispatch/ITypeInfo methods.

沒有留言: