Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] problem with CDOSession - how to close it ?
[CDO] problem with CDOSession - how to close it ? [message #1387131] Tue, 24 June 2014 10:22 Go to next message
Arek Kowal is currently offline Arek KowalFriend
Messages: 10
Registered: April 2014
Junior Member
Hi,

my situation:

public List<A> getBF(final long bFUid, CDOView cdoView)   // !!! one session with one view for all requests in app !!!
    {
        final List<F> bF = new ArrayList<F>();
      
        String bFQuery = "select * from ...";
               
        CDOQuery bFCqo = cdoView.createQuery("sql", bFQuery);
        
        bF.add(bFCqo.getResultValue(F.class));
        
        List<A> bA = new ArrayList<A>();

        for (A a : bF.get(0).getOA()) {
            if (a.isOK()) {
                bA.add(a);
            }
        }
        
        return bA;
    }



so... everything works ok...

but in my case, I must have one session and one view per each request, so I modify above code in this way:

public List<A> getBF(final long bFUid)  
    {
        final List<F> bF = new ArrayList<F>();
      
        String bFQuery = "select * from ...";

    [b] CDOSession cdoSession = STH.openSession();
        CDOView cdoView = cdoSession.openView();[/b]
               
        CDOQuery bFCqo = cdoView.createQuery("sql", bFQuery);
        
        bF.add(bFCqo.getResultValue(F.class));
        
        List<A> bA = new ArrayList<A>();

        for (A a : bF.get(0).getOA()) {
            if (a.isOK()) {
                bA.add(a);
            }
        }

     [b]cdoView.close();
        cdoSession.close(); [/b]  // probably closing doesn't work... because I have an error: OutOfMemoryError
        
        return bA;
    }



Caused by: java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Unknown Source)
at org.eclipse.internal.net4j.buffer.BufferPool.doActivate(BufferPool.java:177)
at org.eclipse.net4j.util.lifecycle.Lifecycle.internalActivate(Lifecycle.java:76)
at org.eclipse.net4j.util.lifecycle.Lifecycle.activate(Lifecycle.java:162)
at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:114)
at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:104)
at org.eclipse.net4j.util.container.ManagedContainer.activateElement(ManagedContainer.java:340)
at org.eclipse.net4j.util.container.ManagedContainer.getElement(ManagedContainer.java:325)
at org.eclipse.net4j.util.container.ManagedContainer.getElement(ManagedContainer.java:301)
at org.eclipse.net4j.TransportInjector.getBufferProvider(TransportInjector.java:102)
at org.eclipse.net4j.TransportInjector.processConnector(TransportInjector.java:83)
at org.eclipse.net4j.TransportInjector.process(TransportInjector.java:51)
at org.eclipse.net4j.util.container.ManagedContainer.postProcessElement(ManagedContainer.java:570)
at org.eclipse.net4j.util.container.ManagedContainer.getElement(ManagedContainer.java:321)
at org.eclipse.net4j.util.container.ManagedContainer.getElement(ManagedContainer.java:301)
at org.eclipse.net4j.tcp.TCPUtil.getConnector(TCPUtil.java:65)
...
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
... 37 more



init method from my STH class:

private void init(IConfigurationAdapter clientConfigurationAdapter)
    { 
        OMPlatform.INSTANCE.setDebugging(false);
        OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
        OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);

        IManagedContainer container = ContainerUtil.createContainer();
        Net4jUtil.prepareContainer(container);
        TCPUtil.prepareContainer(container);
        CDONet4jUtil.prepareContainer(container);
        container.activate();

        IConnector connector = TCPUtil.getConnector(container, clientConfigurationAdapter.getCDOServerAddress());

        configuration = CDONet4jUtil.createNet4jSessionConfiguration();
        configuration.setConnector(connector);
        configuration.setRepositoryName("sth");
    }



Could you have any idea how to close session correctly ?

thanks
Arek




!!!! Probably my error, I run init() per each request...

[Updated on: Tue, 24 June 2014 11:04]

Report message to a moderator

Re: [CDO] problem with CDOSession - how to close it ? [message #1387187 is a reply to message #1387131] Tue, 24 June 2014 18:16 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Arek,

It's impossible for me to tell what exactly these As are that you return form your method, but if they're CDOObjects you
*must not* close the view that has loaded them. Otherwise you get exceptions when you use these objects later.

Opening CDOSessions is comparingly expensive (as opposed to opening views on a session). Closing them deletes the
valuable revision cache that makes CDO fast. I don't know what requirements you have or why, but I'd try everything to
reuse CDOSessions as long as possible.

If you get OutOfMemoryError you must use a profiler to find out why exactly it's caused. CDO most likely doesn't contain
memory leaks after ten years anymore or they would have been reported before. So it's likely that either

1) You have a memory leak in your part of the code or
2) Your program just requires more memory than you've given it

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Am 24.06.2014 12:22, schrieb Arek Kowal:
> Hi,
>
> my situation:
>
> public List<A> getBF(final long bFUid, CDOView cdoView) // !!! one session with one view for all requests in app !!!
> {
> final List<F> bF = new ArrayList<F>();
> String bFQuery = "select * from ...";
> CDOQuery bFCqo = cdoView.createQuery("sql", bFQuery);
> bF.add(bFCqo.getResultValue(F.class));
> List<A> bA = new ArrayList<A>();
>
> for (A a : bF.get(0).getOA()) {
> if (a.isOK()) {
> bA.add(a);
> }
> }
> return bA;
> }
>
> so... everything works ok...
>
> but in my case, I must have one session and one view per each request, so I modify above code in this way:
>
> public List<A> getBF(final long bFUid) {
> final List<F> bF = new ArrayList<F>();
> String bFQuery = "select * from ...";
>
> CDOSession cdoSession = STH.openSession();
> CDOView cdoView = cdoSession.openView();
> CDOQuery bFCqo = cdoView.createQuery("sql", bFQuery);
> bF.add(bFCqo.getResultValue(F.class));
> List<A> bA = new ArrayList<A>();
>
> for (A a : bF.get(0).getOA()) {
> if (a.isOK()) {
> bA.add(a);
> }
> }
>
> cdoView.close();
> cdoSession.close(); // probably closing doesn't work... because I have an error: OutOfMemoryError
> return bA;
> }
>
> Caused by: java.lang.OutOfMemoryError: unable to create new native thread
> at java.lang.Thread.start0(Native Method)
> at java.lang.Thread.start(Unknown Source)
> at org.eclipse.internal.net4j.buffer.BufferPool.doActivate(BufferPool.java:177)
> at org.eclipse.net4j.util.lifecycle.Lifecycle.internalActivate(Lifecycle.java:76)
> at org.eclipse.net4j.util.lifecycle.Lifecycle.activate(Lifecycle.java:162)
> at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:114)
> at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:104)
> at org.eclipse.net4j.util.container.ManagedContainer.activateElement(ManagedContainer.java:340)
> at org.eclipse.net4j.util.container.ManagedContainer.getElement(ManagedContainer.java:325)
> at org.eclipse.net4j.util.container.ManagedContainer.getElement(ManagedContainer.java:301)
> at org.eclipse.net4j.TransportInjector.getBufferProvider(TransportInjector.java:102)
> at org.eclipse.net4j.TransportInjector.processConnector(TransportInjector.java:83)
> at org.eclipse.net4j.TransportInjector.process(TransportInjector.java:51)
> at org.eclipse.net4j.util.container.ManagedContainer.postProcessElement(ManagedContainer.java:570)
> at org.eclipse.net4j.util.container.ManagedContainer.getElement(ManagedContainer.java:321)
> at org.eclipse.net4j.util.container.ManagedContainer.getElement(ManagedContainer.java:301)
> at org.eclipse.net4j.tcp.TCPUtil.getConnector(TCPUtil.java:65)
> ..
> at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
> at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
> .. 37 more
>
>
>
> init method from my STH class:
>
> private void init(IConfigurationAdapter clientConfigurationAdapter)
> { OMPlatform.INSTANCE.setDebugging(false);
> OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
> OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
>
> IManagedContainer container = ContainerUtil.createContainer();
> Net4jUtil.prepareContainer(container);
> TCPUtil.prepareContainer(container);
> CDONet4jUtil.prepareContainer(container);
> container.activate();
>
> IConnector connector = TCPUtil.getConnector(container, clientConfigurationAdapter.getCDOServerAddress());
>
> configuration = CDONet4jUtil.createNet4jSessionConfiguration();
> configuration.setConnector(connector);
> configuration.setRepositoryName("sth");
> }
>
>
> Could you have any idea how to close session correctly ?
>
> thanks
> Arek
>


Previous Topic:Command grouping in CommandStack
Next Topic:[CDO] Info about lock owner and breaking lock
Goto Forum:
  


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

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

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

Back to the top