Our application manages the Entities itself, so we close the EntityManager after every creating and using. We find a slow memleak in our application recently, and by trace of Entity construct and finalize, we found the problem is caused by bad state of EntityManager. After first throwing the InternalException, the EntityManager throws every time when doing merge operation, but it can be closed and retrieved by EntityManagerFactory, and the instances of Entity constructed by ObjectDB can never be released by JVM.There is a chart describes the instances exists in memory. We had checked the heap dump and found the numerous instances were referenced by ObjectDB. ([ObjectDB 2.3.6_14])
com.objectdb.o.InternalException: Unexpected internal exception at com.objectdb.o.JPE.h(JPE.java:163) ~[JPE.class:na] at com.objectdb.o.ERR.f(ERR.java:69) ~[ERR.class:na] at com.objectdb.o.OBC.onObjectDBError(OBC.java:1493) ~[OBC.class:na] at com.objectdb.jpa.EMImpl.rollback(EMImpl.java:295) ~[EMImpl.class:na] at com.app.dao.impl.ObjectdbExpeditionDAO.batchUpdateExpedition(ObjectdbExpeditionDAO.java:122) ~[ObjectdbExpeditionDAO.class:na] at com.app.ExpeditionManager.updateAllExpeditions(ExpeditionManager.java:287) [ExpeditionManager.class:na] at com.app.ExpeditionManager.run(ExpeditionManager.java:390) [ExpeditionManager.class:na] at java.lang.Thread.run(Thread.java:619) [na:1.6.0_21] java.lang.NullPointerException: null