Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT Browser Extensions and COM Object Disposals in WebSite
SWT Browser Extensions and COM Object Disposals in WebSite [message #459818] Wed, 17 August 2005 21:57 Go to next message
Chris is currently offline ChrisFriend
Messages: 97
Registered: July 2009
Member
We have an instance working on code inherited from another source two
questions have arisen that have stemmed from a COM object memory leak:

1. Is the org.eclipse.swt.browser.Browser intended to be subclassed?
Currently there is a sub class of Browser calling the super constructor
inherited from Browser, which creates a WebSite and OleAutomation object.
The sub class constructor then disposes of the WebSite and OleAutomation
object to replace them with subclasses of each. The class file seems to
be an attempt to write a stand alone class rather than a sub class of
Browser.

2. In org.eclipse.swt.browser.WebSite what was the intent for having the
disposeCOMInterfaces() method as protected and how does it fit into the
life-cycle for the WebSite object?
To fix the leak we have implemented a public disposeCOMInterfaces()
method in the subclass of the Browser to clean up the COMObjects in the
WebSite subclass as it seems the disposeCOMInterfaces() method is not
being called. How should the life-cyle of WebSite take place from
creation to disposal with interactions from the COMObjects?

Thanks in advance.
Re: SWT Browser Extensions and COM Object Disposals in WebSite [message #460183 is a reply to message #459818] Mon, 22 August 2005 15:47 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Chris,

Browser and WebSite are not intended to be subclassed, similar to most swt
widgets. The create/disposeCOMInterfaces methods are protected because
that's their visibility in the OleClientSite superclass (it's an
implementation detail, not an implication that subclasses should override
them).

Whenever a Browser is disposed it disposes its OleAutomation, which
Release()s the WebSite, which (through a small framework) calls the
WebSite's disposeCOMInterfaces. I've verified that this is working with a
simple Browser example, so it's hard to say why disposeCOMInterfaces is not
being called in your modified context.

I would suggest putting some breakpoints in Browser/WebSite and watching
what they do at creation and disposal time (use a simple Browser example
like the one below), and then seeing how close the custom subclasses come to
doing something similar.

public static void main(String[] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setBounds (10,10,200,200);
final Browser browser = new Browser(shell, SWT.NONE);
browser.setBounds(10,10,100,100);
browser.setUrl("http://www.google.ca");
shell.open ();
while (!shell.isDisposed ()){
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}

Grant

"Chris" <chris@asdf.com> wrote in message
news:77849720cc1886a7958c047a31bfc01e$1@www.eclipse.org...
> We have an instance working on code inherited from another source two
> questions have arisen that have stemmed from a COM object memory leak:
>
> 1. Is the org.eclipse.swt.browser.Browser intended to be subclassed?
> Currently there is a sub class of Browser calling the super constructor
> inherited from Browser, which creates a WebSite and OleAutomation object.
> The sub class constructor then disposes of the WebSite and OleAutomation
> object to replace them with subclasses of each. The class file seems to
> be an attempt to write a stand alone class rather than a sub class of
> Browser.
>
> 2. In org.eclipse.swt.browser.WebSite what was the intent for having the
> disposeCOMInterfaces() method as protected and how does it fit into the
> life-cycle for the WebSite object?
> To fix the leak we have implemented a public disposeCOMInterfaces()
> method in the subclass of the Browser to clean up the COMObjects in the
> WebSite subclass as it seems the disposeCOMInterfaces() method is not
> being called. How should the life-cyle of WebSite take place from
> creation to disposal with interactions from the COMObjects?
>
> Thanks in advance.
>
Previous Topic:Minimum size for a dialog
Next Topic:packing first column of a TableTree
Goto Forum:
  


Current Time: Thu Apr 25 05:27:51 GMT 2024

Powered by FUDForum. Page generated in 0.03031 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top