Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] memory leak while using OLE automation

The correct way to release the resources for OleAutomation and
OleClientSite is to call "dispose". The dispose method will manage the
reference count.

 The "disposeCOMInterfaces" is called when the reference count for the
related interfaces is 0.  You do not need to call it yourself.

There is a weakness in my Variant story however.  Variant really should
have a dispose method too.

The reason is that when you get a Variant with IDispatch or IUnknown
inside, Variant calls AddRef on the interface (in setData).  Then when you
call getAutomation, another AddRef is called on the IDispatch interface.
The OleAutomation.dispose calls Release once but there is still an
outstanding AddRef to be cancelled.  The Variant.dispose method should take
care of this.  As a workaround, you could call Variant.getDispatch and call
Release on the IDispatch object.

I will add the dispose method to Variant in 2.1 (see bug report
http://dev.eclipse.org/bugs/show_bug.cgi?id=25383).

You could also check out the ref count for OleClientSite (add a print
statement in OleClientSite.Release). It is possible that the ref count is
not going down to zero which would result in the vtables for the COM
interfaces being leaked (this would leak about 156 bytes for each
OleClientSite).



                                                                                                                                                     
                      "Gupta, Saurabh [IT]"                                                                                                          
                      <saurabh.gupta@citigrou         To:      platform-swt-dev@xxxxxxxxxxx                                                          
                      p.com>                          cc:                                                                                            
                      Sent by:                        Subject: [platform-swt-dev] memory leak while using OLE automation                             
                      platform-swt-dev-admin@                                                                                                        
                      eclipse.org                                                                                                                    
                                                                                                                                                     
                                                                                                                                                     
                      25/10/2002 09:36 AM                                                                                                            
                      Please respond to                                                                                                              
                      platform-swt-dev                                                                                                               
                                                                                                                                                     
                                                                                                                                                     



Hi,
I am using the OLE Automation classes in SWT to convert some of my Excel
files into Text delimitted files, and I am finding that there is a
potential
memory leak problem. The JVM crashes after 60,000 iterations with the
exception
org.eclipse.swt.SWTException: Failed to create Ole Client. result =
-2146959355
at org.eclipse.swt.ole.win32.OLE.error(OLE.java:291)
at org.eclipse.swt.ole.win32.OleClientSite.<init>(OleClientSite.java:186)

I have checked all the dispose() and garbage disposal mechanisms for
OleClientSite, OleAutomation, Shell and other classes.

Does anyone know if this is a known bug??
Is the standard way to dispose OleClientSite is to just call dispose() ??

Also, one interesting thing that I found in the SWT code was that there is
a
protected method in OleClientSite named disposeCOMInterfaces() does all the
disposing related to ceratin member COMObject "iUnknown, iOleInPlaceSite".
I do not know if I should be calling disposeCOMInterfaces() as well , (but
I
can't because it is protected)??

any help is appreciated.

thanks
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev






Back to the top