openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacob Nowosatka (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.
Date Fri, 19 Aug 2011 18:10:29 GMT

     [ https://issues.apache.org/jira/browse/OPENJPA-2042?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jacob Nowosatka updated OPENJPA-2042:
-------------------------------------

    Attachment: TestEMFMemoryLeak.java

> Diagnostics for Application Managed EntityManagerFactory leaks.
> ---------------------------------------------------------------
>
>                 Key: OPENJPA-2042
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2042
>             Project: OpenJPA
>          Issue Type: Improvement
>            Reporter: Jacob Nowosatka
>            Priority: Minor
>         Attachments: TestEMFMemoryLeak.java
>
>
> EntityManagerFactories can be leaked if they are created with the JSE bootstrap Persistence
class and are never closed, causing an OutOfMemoryException.
> One possibility may be to log a warning or otherwise alert the developer when the number
of unclosed EMF's reaches a certain threshold. An extra step could be taken here to track
where the EMF's are being opened and which ones aren't being closed as to show the developer
exactly where in the code the problem is occurring.
> There may be a possibility to eliminate this leak by making the references to the EMF's
weak and let the garbage collector clean up the unclosed EMF's. However, in the case that
other objects are being leaked as well, this change may make it harder to detect such leaks.
> I ran a simple test that creates a EMF from Persistence. It then creates and closes an
EntityManger. A new EMF is then created without closing the old one, effectively "leaking"
it. As expected, this results in an OutOfMemoryException. When using weak references on the
EMF's, I was able to get the test to run all night without a trace of any heap growth. However,
this is only a very simple test and a test with more Entities/Configurations/etc. may result
in heap growth due to other objects being leaked(as mentioned earlier). My test case is attached.
> For comparison, I tried the same test on Hibernate and EclipseLink. Hibernate runs into
the same OutOfMemoryException. EclipseLink does not.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message