A lot of ENT and SIV instances which are not cleared by GC

#1

Hello.

I have a JSF application (Glassfish 4, Java 8, ObjectDB 2.6.0). In some time the heap is getting 95% full with java.lang.OutOfMemoryError: GC overhead limit exceeded.  The first screenshot from VisualVM shows used heap during a 1000 requests stress test. The second shows that after this test there are many com.objectdb.o.ENT and com.objectdb.o.SIV instances. Why isn't it cleaned? I use simple EJB managers containing EntityManagers. On bean's PreDestroy and in servlet's i make entityManager.clear();

#2

Every managed entity object is associated with an helper ENT object. entityManager.clear() should release strong references to ENT objects.

Are you using enhanced classes? Are you using "objectdb.temp.no-detach"?

Try to find the roots and paths to the ENT objects (using VisualVM) that keep them strongly reachable.

ObjectDB Support
#3

Yes, I use no-detach option. So how can I fix it? Remove no-detach? But it has negative effects too.

#4

With "objectdb.temp.no-detach" enabled, clear() is silently ignored.

But you should be able to explicitly detach specific objects.

 

ObjectDB Support
#5

Some objects cannot be detached. They throw this exception:

Please report this error on http://www.objectdb.com/database/issue/new
com.objectdb.o.InternalException: java.lang.NullPointerException: null
java.lang.NullPointerException
at com.objectdb.o.LDR.H(LDR.java:687)
at com.objectdb.o.LDR.G(LDR.java:619)
at com.objectdb.o.LDR.E(LDR.java:472)
at com.objectdb.o.OBC.UO(OBC.java:1080)
at com.objectdb.o.QRR.f(QRR.java:222)
at com.objectdb.o.QRR.a(QRR.java:618)
at com.objectdb.o.InvMemberQuery.e(InvMemberQuery.java:139)
at com.objectdb.o.UMR.v(UMR.java:508)
at com.objectdb.o.ENT.loadInverse(ENT.java:1472)
at com.objectdb.o.IVP.m(IVP.java:149)
at com.objectdb.o.IVP.l(IVP.java:137)
at com.objectdb.o.ILP.size(ILP.java:232)
at com.objectdb.o.CLT.visitRefs(CLT.java:156)
at com.objectdb.o.TVS.j(TVS.java:169)
at com.objectdb.o.TVS.cascade(TVS.java:156)
at com.objectdb.o.TVS.g(TVS.java:105)
at com.objectdb.o.TVS.g(TVS.java:93)
at com.objectdb.jpa.EMImpl.detach(EMImpl.java:499)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.detach(EntityManagerWrapper.java:914)
at ru.mycityseason.managers.Manager.detachAll(Manager.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
at sun.reflect.GeneratedMethodAccessor119.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
at sun.reflect.GeneratedMethodAccessor120.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4667)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at com.sun.proxy.$Proxy353.detachAll(Unknown Source)
at ru.mycityseason.managers.__EJB31_Generated__WearManager__Intf____Bean__.detachAll(Unknown Source)
at ru.mycityseason.beans.ShowCollectionsBean.destroy(ShowCollectionsBean.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.invokeMethods(DefaultLifecycleCallbackInvoker.java:89)
at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.preDestroy(DefaultLifecycleCallbackInvoker.java:82)
at org.jboss.weld.injection.producer.BasicInjectionTarget.preDestroy(BasicInjectionTarget.java:99)
at org.jboss.weld.injection.producer.BeanInjectionTarget.preDestroy(BeanInjectionTarget.java:73)
at org.jboss.weld.bean.ManagedBean.destroy(ManagedBean.java:186)
at org.jboss.weld.context.ForwardingContextual.destroy(ForwardingContextual.java:31)
at org.jboss.weld.context.AbstractContext.destroyContextualInstance(AbstractContext.java:150)
at org.jboss.weld.context.AbstractContext.destroy(AbstractContext.java:163)
at org.jboss.weld.context.AbstractManagedContext.deactivate(AbstractManagedContext.java:41)
at org.jboss.weld.context.AbstractBoundContext.deactivate(AbstractBoundContext.java:72)
at org.jboss.weld.context.http.HttpRequestContextImpl.deactivate(HttpRequestContextImpl.java:70)
at org.jboss.weld.servlet.WeldListener.requestDestroyed(WeldListener.java:154)
at org.apache.catalina.core.StandardContext.fireRequestDestroyedEvent(StandardContext.java:5261)
at org.apache.catalina.core.StandardHostValve.postInvoke(StandardHostValve.java:255)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:359)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:745)

I don't see any differences of this entities from another ones. Also I've added cascade=CascadeType.DETACH or CascadeType.ALL to every relationship because it doesn't detach without it.

#6

Following your report we found and fixed (in build 2.6.1_01) a bug in cascading detach through mapped by to-many relationships.

Please check the new build. If you still get the exception we may need a test case that demonstrate the issue in order to explore it further.

ObjectDB Support
#7

Thanks, no exception now. However there are still unremovable objects, but it may be JSF's problem because I see destroyed but long time unremoved RequestScoped bean in the heap.

Reply