You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Jacob Nowosatka (JIRA)" <ji...@apache.org> on 2011/08/19 19:54:27 UTC

[jira] [Created] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

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


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

        

Re: [jira] [Created] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

Posted by Pinaki Poddar <pp...@apache.org>.
Hi Jacob,
> 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.

Do you attach the patch to JIRA issue that uses weak references for EMF?
It will be an useful addition.

-----
Pinaki Poddar
Chair, Apache OpenJPA Project
--
View this message in context: http://openjpa.208410.n2.nabble.com/jira-Created-OPENJPA-2042-Diagnostics-for-Application-Managed-EntityManagerFactory-leaks-tp6704354p6704694.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.

[jira] [Updated] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2042?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Dick updated OPENJPA-2042:
----------------------------------

    Affects Version/s: 1.0.4
                       1.2.2
                       2.0.1
                       2.1.0

> Diagnostics for Application Managed EntityManagerFactory leaks.
> ---------------------------------------------------------------
>
>                 Key: OPENJPA-2042
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2042
>             Project: OpenJPA
>          Issue Type: Improvement
>    Affects Versions: 1.0.4, 1.2.2, 2.0.1, 2.1.0
>            Reporter: Jacob Nowosatka
>            Assignee: Michael Dick
>            Priority: Minor
>             Fix For: 2.2.0
>
>         Attachments: OPENJPA-2042.patch, 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

        

[jira] [Closed] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

Posted by "Albert Lee (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2042?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Albert Lee closed OPENJPA-2042.
-------------------------------


Close issue in preparation for 2.2.0 release.
                
> Diagnostics for Application Managed EntityManagerFactory leaks.
> ---------------------------------------------------------------
>
>                 Key: OPENJPA-2042
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2042
>             Project: OpenJPA
>          Issue Type: Improvement
>    Affects Versions: 1.0.4, 1.2.2, 2.0.1, 2.1.0
>            Reporter: Jacob Nowosatka
>            Assignee: Rick Curtis
>            Priority: Minor
>             Fix For: 2.2.0
>
>         Attachments: OPENJPA-2042.patch, 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.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-2042?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13099041#comment-13099041 ] 

Rick Curtis commented on OPENJPA-2042:
--------------------------------------

Jake - Do you have a patch to fix this issue?

> 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

        

[jira] [Updated] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

Posted by "Jacob Nowosatka (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2042?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

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

    Attachment:     (was: 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

        

[jira] [Resolved] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2042?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Dick resolved OPENJPA-2042.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.2.0

The patch looks good, thanks Jacob. 

> Diagnostics for Application Managed EntityManagerFactory leaks.
> ---------------------------------------------------------------
>
>                 Key: OPENJPA-2042
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2042
>             Project: OpenJPA
>          Issue Type: Improvement
>    Affects Versions: 1.0.4, 1.2.2, 2.0.1, 2.1.0
>            Reporter: Jacob Nowosatka
>            Assignee: Michael Dick
>            Priority: Minor
>             Fix For: 2.2.0
>
>         Attachments: OPENJPA-2042.patch, 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

        

[jira] [Commented] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

Posted by "Rick Curtis (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-2042?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13145567#comment-13145567 ] 

Rick Curtis commented on OPENJPA-2042:
--------------------------------------

Committed revision 1198786 to trunk. I added a null check in PCRegistry to fix the following problem:

Caused by: java.lang.NullPointerException
	at org.apache.openjpa.enhance.PCRegistry.register(PCRegistry.java:210)
	at org.apache.openjpa.persistence.jdbc.maps.m2mmapex3.FullName.<clinit>(FullName.java)
	... 38 more

                
> Diagnostics for Application Managed EntityManagerFactory leaks.
> ---------------------------------------------------------------
>
>                 Key: OPENJPA-2042
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2042
>             Project: OpenJPA
>          Issue Type: Improvement
>    Affects Versions: 1.0.4, 1.2.2, 2.0.1, 2.1.0
>            Reporter: Jacob Nowosatka
>            Assignee: Rick Curtis
>            Priority: Minor
>             Fix For: 2.2.0
>
>         Attachments: OPENJPA-2042.patch, 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.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

Posted by "Jacob Nowosatka (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2042?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

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

    Attachment: OPENJPA-2042.patch

Patch changes the references to EMF's to weak references.

> 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: OPENJPA-2042.patch, 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

        

[jira] [Updated] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

Posted by "Jacob Nowosatka (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2042?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

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

    Attachment:     (was: 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

        

[jira] [Resolved] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

Posted by "Rick Curtis (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2042?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Curtis resolved OPENJPA-2042.
----------------------------------

    Resolution: Fixed
    
> Diagnostics for Application Managed EntityManagerFactory leaks.
> ---------------------------------------------------------------
>
>                 Key: OPENJPA-2042
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2042
>             Project: OpenJPA
>          Issue Type: Improvement
>    Affects Versions: 1.0.4, 1.2.2, 2.0.1, 2.1.0
>            Reporter: Jacob Nowosatka
>            Assignee: Rick Curtis
>            Priority: Minor
>             Fix For: 2.2.0
>
>         Attachments: OPENJPA-2042.patch, 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.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2042?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Dick reassigned OPENJPA-2042:
-------------------------------------

    Assignee: Michael Dick

> 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
>            Assignee: Michael Dick
>            Priority: Minor
>         Attachments: OPENJPA-2042.patch, 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

        

[jira] [Updated] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

Posted by "Jacob Nowosatka (JIRA)" <ji...@apache.org>.
     [ 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

        

[jira] [Updated] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

Posted by "Jacob Nowosatka (JIRA)" <ji...@apache.org>.
     [ 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

        

[jira] [Reopened] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks.

Posted by "Rick Curtis (Reopened) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2042?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Curtis reopened OPENJPA-2042:
----------------------------------

      Assignee: Rick Curtis  (was: Michael Dick)

Reopening this issue as I think this might be causing a failure on Jenkins[1].

[1] https://builds.apache.org/job/OpenJPA-trunk-deploy/org.apache.openjpa$openjpa-persistence-jdbc/200/consoleText
                
> Diagnostics for Application Managed EntityManagerFactory leaks.
> ---------------------------------------------------------------
>
>                 Key: OPENJPA-2042
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2042
>             Project: OpenJPA
>          Issue Type: Improvement
>    Affects Versions: 1.0.4, 1.2.2, 2.0.1, 2.1.0
>            Reporter: Jacob Nowosatka
>            Assignee: Rick Curtis
>            Priority: Minor
>             Fix For: 2.2.0
>
>         Attachments: OPENJPA-2042.patch, 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.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira