Return-Path: X-Original-To: apmail-openjpa-dev-archive@www.apache.org Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 756187A67 for ; Mon, 7 Nov 2011 14:37:19 +0000 (UTC) Received: (qmail 46659 invoked by uid 500); 7 Nov 2011 14:37:19 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 46615 invoked by uid 500); 7 Nov 2011 14:37:18 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 46607 invoked by uid 99); 7 Nov 2011 14:37:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Nov 2011 14:37:18 +0000 X-ASF-Spam-Status: No, hits=-2001.2 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Nov 2011 14:37:12 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id D771F38932 for ; Mon, 7 Nov 2011 14:36:51 +0000 (UTC) Date: Mon, 7 Nov 2011 14:36:51 +0000 (UTC) From: "Rick Curtis (Reopened) (JIRA)" To: dev@openjpa.apache.org Message-ID: <1226046873.6705.1320676611883.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <2004132806.53637.1313776467231.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Reopened] (OPENJPA-2042) Diagnostics for Application Managed EntityManagerFactory leaks. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on 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