[ 
https://issues.apache.org/jira/browse/OPENJPA-1161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12728415#action_12728415
 ] 

brian yoder commented on OPENJPA-1161:
--------------------------------------

After narrowing in on the exact code it seems the following code is the cause:

EntityManagerFactory emf = OpenJPAPersistence.createEntityManagerFactory(...);

But when emf is GC (or no longer reachable) it doesn't clean up after itself.  
I tried to call emf.close() and set to NULL, but still there are all the 
mappings (MappingRepository) created for the emf.

I would think that when the finalize method is called for EntityManagerFactory 
it should clean up after itself, since when there would be no point in having 
cache maintained after the emf is no longer reachable.

I was using IBM WebSphere 6.1.0.25 that uses the 
"com.ibm.ws.persistence.EntityManagerFactoryImpl" implementation, and after 
reviewing the java histogram when the out of memory error occured I found that 
the EntityManagerFactoryImpl objects were GC (since there was only 16), however 
the MappingRepository was stuck at 2846.

Object Histogram:

Size    Count   Class description
-------------------------------------------------------
384     16      com.ibm.ws.persistence.EntityManagerFactoryImpl
409824  2846    org.apache.openjpa.jdbc.meta.MappingRepository

I can provide more information if needed, but I can tell you there are other 
developers that are having the same issue, the only work arround is to create a 
single EntityManagerFactory instance per JVM (or classloader) - since there 
seems to be no way to manually clean them up.




> Identified MemoryLeak in MappingRepository
> ------------------------------------------
>
>                 Key: OPENJPA-1161
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1161
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.0.4
>            Reporter: brian yoder
>         Attachments: screenshot-1.jpg
>
>
> After a lot of testing I have reproduced a specific scenario where the 
> MappingRepository instances grow, and eventually an OutOfMemory error will 
> occur.  There have been other reports of this occuring, but no response from 
> Apache yet, so I am opening a new bug.  I will attach the code wich causes 
> the issue, and a screen shot of the memory leaking classes.
> Note: This may be related to OPENJPA-746

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to