ObjectDB ObjectDB

Memory leak with OutOfMemoryError exception

#1

Hi,

I'm new to using object databases. Currently I'm experience the following error:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at com.objectdb.o.EBW.<init>(EBW.java:31)
        at com.objectdb.spi.OWriter.<init>(OWriter.java:26)
        at com.objectdb.o.TYW.<init>(TYW.java:97)
        at com.objectdb.o.ENH.c(ENH.java:197)
        at com.objectdb.o.ENT.T(ENT.java:821)
        at com.objectdb.o.LDR.y(LDR.java:484)
        at com.objectdb.o.LDR.x(LDR.java:448)
        at com.objectdb.o.LDR.s(LDR.java:161)
        at com.objectdb.o.OBC.aM(OBC.java:1068)
        at com.objectdb.o.OBC.aK(OBC.java:968)
        at com.objectdb.o.OBC.UG(OBC.java:809)
        at com.objectdb.o.QRR.h(QRR.java:273)
        at com.objectdb.o.QRR.b(QRR.java:175)
        at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:686)
        at newstockscreener.DBDataRetriever.getDailyEntriesForSymbol(DBDataRetriever.java:53)
        at newstockscreener.StockIterator.iterate(StockIterator.java:35)
        at newstockscreener.Runner.main(Runner.java:23)

I think you've mentioned that stack traces arent as helpful. The following method is where I suspect the leak is:

public List<DailyEntry>  getDailyEntriesForSymbol(final StockProfile symbol)
{
    EntityManager em = GO.emf.createEntityManager();

    TypedQuery<DailyEntry> q = em.createQuery("SELECT d FROM DailyEntry d "
            + "where d.symbol = :symbol", DailyEntry.class);
    q.setParameter("symbol", symbol);

    List<DailyEntry> results = q.getResultList();

    em.close();

    return results;
}

The method above is called from:

for (final StockProfile symbol : symbols)
{
    final List<DailyEntry> dailyEntries =
       GO.dataRetriever.getDailyEntriesForSymbol(symbol);
}

There are about 18 million DailyEntry records in the database that is sifted through to get the DailyEntries for each symbol.

I am also using VirtualVM where I notice the used heap space continue to grow till the crash. A heap dump shows:

com.objectdb.o.RFV 33.016272394439966 642982 (33%) 18003496 (13%)
byte[] 18.0291352369998 351112 (18%) 83005789 (59.8%)
com.objectdb.o.SLV 16.62546791478174 323776 (16.6%) 7770624 (5.6%)
com.objectdb.o.RSV 16.39265303188239 319242 (16.4%) 10215744 (7.4%)
java.lang.Object 6.079066686521487 118388 (6.1%) 1894208 (1.4%)

as the top instances.

I am using objectdb-2.3.7.

I would appreciate any help and guidance you can provide to determine the cause behind this.

Thank you in advance.

edit
delete
#2

Apparently you are using the default Java heap size (128MB) and this is not sufficient.

You may try increasing the Java heap size by running your application (and ObjectDB Server in client server mode) using the -Xmx flag, or alternatively you will have to decrease the following default ObjectDB settings:

ObjectDB Support
edit
delete
#3

Upping the max heap size to 256M has solved this problem. Thank you!

edit
delete

Reply

To post on this website please sign in.