win32com and MSHTML

Peter Parente parente at cs.unc.edu
Sat Mar 29 09:25:38 EST 2003


> Reduce it down to a simple example that repeatedly reloads the same
> document, connecting each time.  From what you describe, you will notice
> pythoncom._GetInterfaceCount() increasing without bound.  If there is a
> simple win32com bug, you should be able to demonstrate this with very
> few lines of code.


I constructed a very simple example that watches an IE window to see when it
starts and changes pages. All it does is re-obtain the document each time a
new page loads in the OnLoad IE event and discards it by calling
self.doc.close() and del self.doc in the OnBeforeUnload event. I do see the
reference count growing without bound like this:

Before grabbing window: 8
After grabbing window: 10
Before acquiring doc for the first time: 10
After grabbing doc for the first time: 12

After refreshing the page once I see:

After closing doc: 12
After deleting doc: 12
Before acquiring doc again: 12
After grabbing doc again: 14

Refreshing again gives another increase by the same amount. However, if I
close that IE window and open a new one, the refrence count drops back to
how it started for the first browser window. To my untrained eye, it looks
like the objects are getting held by IE until it quits and are causing the
slowdown.

Pete






More information about the Python-list mailing list