Return-Path: X-Original-To: apmail-db-derby-user-archive@www.apache.org Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EF6BEDF67 for ; Wed, 27 Jun 2012 14:20:38 +0000 (UTC) Received: (qmail 42541 invoked by uid 500); 27 Jun 2012 14:20:38 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 42505 invoked by uid 500); 27 Jun 2012 14:20:38 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 42496 invoked by uid 99); 27 Jun 2012 14:20:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Jun 2012 14:20:38 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=FSL_RCVD_USER,RCVD_IN_DNSWL_HI,SPF_PASS,T_FRT_BELOW2 X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of kristian.waagan@oracle.com designates 148.87.113.117 as permitted sender) Received: from [148.87.113.117] (HELO rcsinet15.oracle.com) (148.87.113.117) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Jun 2012 14:20:27 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q5REK5BY021696 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 27 Jun 2012 14:20:06 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q5REK4us013645 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 27 Jun 2012 14:20:05 GMT Received: from abhmt105.oracle.com (abhmt105.oracle.com [141.146.116.57]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q5REK4HQ025235 for ; Wed, 27 Jun 2012 09:20:04 -0500 Received: from [192.168.0.20] (/84.215.180.161) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 27 Jun 2012 07:20:04 -0700 Message-ID: <4FEB1686.6040305@oracle.com> Date: Wed, 27 Jun 2012 16:19:50 +0200 From: Kristian Waagan User-Agent: Mozilla/5.0 (X11; SunOS i86pc; rv:10.0.3) Gecko/20120424 Thunderbird/10.0.3 MIME-Version: 1.0 To: derby-user@db.apache.org Subject: Re: Strange OutOfMemory in unittest References: <34080334.post@talk.nabble.com> In-Reply-To: <34080334.post@talk.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Source-IP: ucsinet22.oracle.com [156.151.31.94] On 27.06.12 15:15, mogoye wrote: > > Hello, > > I'm currently working on a some junit tests to validate My DB using Derby > 1.8.1.2. > My code is using JPA annotations and Eclipselink implementation. > > The purpose of this test is to evaluate the performances of my requests. > My test is doing the following things : > - Create an empty DB. > - Fill DB with 200 000 entries > - Performs some requests. > - Check answers are Ok and measure time to proccess them. > > The thing I don't understant is why my test can be executed 50% of the time > with no problem, and the other 50% I have OutOfMemory that occurs at various > tests execution. > > I don't understand why the same code executed few seconds later can sometime > be a success or failure. > > > For example here is one of the request that is executed. > In that case the request is a native querry and a very basic request: > SELECT * FROM TICKET ORDER BY EXPECTED_DATE ASC OFFSET 33000 ROWS FETCH > FIRST 20 ROWS ONLY > > > My DB (measured on the file system) is only 100Mb so not very big one > See bellow the stack trace. > > I have no idea how I can go further as I'm not very familliar with derby > tools or logs to help debugging. > > Does any one have some idea ? As already mentioned, you should check what your maximum heap size is set to. If Derby is run with the default page cache size, it normally shouldn't occupy much more than 4 MB of heap. If your VM supports it, you could dump the heap when the OOME occurs [1], or use something like VisualVM (maybe with the visualgc plugin) to observe the memory usage. If you obtain a dump, you have to extract information from it afterwards, for instance with jhat. If you search the web, you'll probably find other tools doing similar things. Note that you can always obtain heap dumps with VisualVM, and information like the max heap size. You could also sample the heap manually by using a tool like jmap to get a heap histogram. In many cases the thread stack trace is a red herring, at least in multi-threaded applications, since the OOME can happen at any place where memory is needed/allocated. Regards, -- Kristian [1] For the Sun/Oracle JVMs that would be -XX:+HeapDumpOnOutOfMemoryError > > Thanks a lot. > Sylvain > > > > > Here is the complete Stack trace I can get (sometimes I do not have any > stack info): > > java.lang.OutOfMemoryError: Java heap space > at > sun.text.resources.DateFormatZoneData.getContents(DateFormatZoneData.java:299) > at > sun.text.resources.DateFormatZoneData.loadLookup(DateFormatZoneData.java:144) > at > sun.text.resources.DateFormatZoneData.getKeys(DateFormatZoneData.java:100) > at > sun.text.resources.DateFormatZoneData.getKeys(DateFormatZoneData.java:105) > at java.text.DateFormatSymbols.loadZoneStrings(DateFormatSymbols.java:449) > at java.text.DateFormatSymbols.initializeData(DateFormatSymbols.java:489) > at java.text.DateFormatSymbols.(DateFormatSymbols.java:103) > at java.util.TimeZone.retrieveDisplayNames(TimeZone.java:412) > at java.util.TimeZone.getDisplayNames(TimeZone.java:401) > at java.util.TimeZone.getDisplayName(TimeZone.java:352) > at java.util.Date.toString(Date.java:1024) > at java.lang.String.valueOf(String.java:2615) > at java.lang.StringBuffer.append(StringBuffer.java:220) > at > org.apache.derby.impl.services.stream.BasicGetLogHeader.getHeader(Unknown > Source) > at org.apache.derby.iapi.error.ErrorStringBuilder.appendln(Unknown Source) > at > org.apache.derby.iapi.services.context.ContextManager.cleanupOnError(Unknown > Source) > at > org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown > Source) > at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown > Source) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown > Source) > at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown > Source) > at > org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown > Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeQuery(Unknown > Source) > at > org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96) > at > org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96) > at > org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:931) > at > org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:607) > at > org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:535) > at > org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1702) > at > org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:566) > at > org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:207) > at > org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193) > at > org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:264) > > > > > >