Re: [dev] why does it leak so hard?

2010-03-09 Thread Oleg Mikheev
 I'm doing a rather primitive thing: load and close a document.
 Question: why does it make OO grow 50Mb/minute?
 
 The Java-side proxy objects (referenced through variable xComponent) 
 keep the OOo-side XComponent objects (representing the opened documents) 
 alive until the JVM garbage collector decides to finalize them. 

Jstat tells me that xComponents are collected.
I even added these two lines of code:

xComponent = null;
System.gc();

to make sure that xComponent objects are collected.

Another observation: if I use TCP connection instead of Name pipes
OO leaks 150Mb/minute instead of 50Mb/minute :-)

Most probably Java UNO implementation doesn't release OO
resources once  XComponent gets garbage collected.

Oleg

-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



[dev] why does it leak so hard?

2010-03-08 Thread Oleg Mikheev
Hi guys and girls,

I'm doing a rather primitive thing: load and close a document.
Question: why does it make OO grow 50Mb/minute?
Code:

import com.sun.star.beans.PropertyValue;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.util.CloseVetoException;
import com.sun.star.util.XCloseable;

public class Test2 {

public static void main(String[] args) throws Exception {
XComponentContext xCompContext =
com.sun.star.comp.helper.Bootstrap.bootstrap();
XMultiComponentFactory xMCF = xCompContext.getServiceManager();
Object xDesktop =
xMCF.createInstanceWithContext(com.sun.star.frame.Desktop, xCompContext);
XComponentLoader aLoader =
UnoRuntime.queryInterface(XComponentLoader.class, xDesktop);
PropertyValue[] loadProps = new PropertyValue[]{new
PropertyValue(Hidden, 0, true, null)};
while (true) {
XComponent xComponent =
aLoader.loadComponentFromURL(file:///tmp/demo.ods, _blank, 0,
loadProps);
close(xComponent);
}
}

private static void close(XComponent xComponent) {
XCloseable xCloseable = 
UnoRuntime.queryInterface(XCloseable.class,
xComponent);
if (xCloseable != null) {
try {
xCloseable.close(false);
} catch (CloseVetoException e) {}
} else xComponent.dispose();
}
}

-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



Re: [dev] why does it leak so hard?

2010-03-08 Thread Stephan Bergmann

On 03/07/10 20:09, Oleg Mikheev wrote:

Hi guys and girls,

I'm doing a rather primitive thing: load and close a document.
Question: why does it make OO grow 50Mb/minute?


The Java-side proxy objects (referenced through variable xComponent) 
keep the OOo-side XComponent objects (representing the opened documents) 
alive until the JVM garbage collector decides to finalize them. 
Presumably, large parts of the OOo data structures for such a document 
are only released once the XComponent object is destroyed, and not 
already when XCloseable.close is called.


-Stephan


Code:

import com.sun.star.beans.PropertyValue;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.util.CloseVetoException;
import com.sun.star.util.XCloseable;

public class Test2 {

public static void main(String[] args) throws Exception {
XComponentContext xCompContext =
com.sun.star.comp.helper.Bootstrap.bootstrap();
XMultiComponentFactory xMCF = xCompContext.getServiceManager();
Object xDesktop =
xMCF.createInstanceWithContext(com.sun.star.frame.Desktop, xCompContext);
XComponentLoader aLoader =
UnoRuntime.queryInterface(XComponentLoader.class, xDesktop);
PropertyValue[] loadProps = new PropertyValue[]{new
PropertyValue(Hidden, 0, true, null)};
while (true) {
XComponent xComponent =
aLoader.loadComponentFromURL(file:///tmp/demo.ods, _blank, 0,
loadProps);
close(xComponent);
}
}

private static void close(XComponent xComponent) {
XCloseable xCloseable = 
UnoRuntime.queryInterface(XCloseable.class,
xComponent);
if (xCloseable != null) {
try {
xCloseable.close(false);
} catch (CloseVetoException e) {}
} else xComponent.dispose();
}
}



-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org