Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZlbYU-0003eN-TJ for pgsql-jdbc@arkaria.postgresql.org; Mon, 12 Oct 2015 11:46:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZlbYU-0002Mo-1q for pgsql-jdbc@arkaria.postgresql.org; Mon, 12 Oct 2015 11:46:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZlbYT-0002Lf-C3 for pgsql-jdbc@postgresql.org; Mon, 12 Oct 2015 11:46:13 +0000 Received: from www.nailedtothex.org ([153.121.39.112]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZlbYP-000795-49 for pgsql-jdbc@postgresql.org; Mon, 12 Oct 2015 11:46:12 +0000 MIME-Version: 1.0 X-UserIsAuth: true Received: from p784b7a14.tksmnt01.ap.so-net.ne.jp (EHLO kyle-no-MacBook.local) ([120.75.122.20]) by www.nailedtothex.org (JAMES SMTP Server ) with ESMTPA ID 922082068 for ; Mon, 12 Oct 2015 20:46:02 +0900 (JST) To: pgsql-jdbc@postgresql.org From: Kohei Nozaki Subject: AbstractJdbc2ResultSet.FAST_NUMBER_FAILED brings class loader leak Message-ID: <561B9D78.8090106@nailedtothex.org> Date: Mon, 12 Oct 2015 20:46:00 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Hello, I'm working on fixing the issue "java.lang.OutOfMemoryError: Metaspace" in the time of redeploy where running an web application on Tomcat. I have acquired a heap dump and found a weird Root GC reference which is connected to org.postgresql.jdbc2.AbstractJdbc2ResultSet. The heap dump shows that it saves a (intentionally constructed) NumberFormatException in a private static final field FAST_NUMBER_FAILED and that field has backtrace field which references a Servlet class that loaded by WebappClassLoader. Here's a screenshot of Eclipse Memory Analyzer: http://www.nailedtothex.org/roller/kyle/mediaresource/2fabd2a0-10a3-4d45-b8c8-589763d15824 I think AbstractJdbc2ResultSet should stop saving a intentionally constructed Exception in a static field because it creates a strong reference to a class which invoked the database operation at the first time regardless if it's loaded by WebappClassLoader. It will be a cause of class loader leak. [Steps to reproduce] 1. Put postgresql-9.3-1100.jdbc41.jar to $TOMCAT_HOME/lib 2. Put following element to $TOMCAT_HOME/conf/context.xml 3. git clone https://github.com/lbtc-xxx/jdbc-servlet 4. cd jdbc-servlet; mvn clean package 5. deploy the WAR 6. visit http://localhost:8080/jdbc-servlet-1.0-SNAPSHOT 7. undeploy and deploy the WAR several times (keep your JVM running) 8. acquire heap dump and load it with Eclipse Memory Analyzer [My environment] * postgresql-9.3-1100.jdbc41.jar * Tomcat 8.0.18 * Oracle JDK 8u60 * PostgreSQL 9.3.4 Thanks. -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc