Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

java.lang.OutOfMemoryError

Developers
2011-03-10
2013-05-14
  • Mukesh Gulia
    Mukesh Gulia
    2011-03-10

    We have started working with EhCahce few days back.
    We need  to read data from input file line by line. then hit the database with some generated query from that line.
    Use the resultSet and frame a output file.

    Now, we are using EhCahce for mapping Query-Result pair so that we need not hit the database for duplicate generated queries.

    Its running all fine but blew up when a resultSet of 2 lakh records encountered.

    [code]
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
            at java.io.ObjectOutputStream$HandleTable.growEntries(ObjectOutputStream.java:2312)
            at java.io.ObjectOutputStream$HandleTable.assign(ObjectOutputStream.java:2237)
            at java.io.ObjectOutputStream.writeString(ObjectOutputStream.java:1262)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1144)
            at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
            at java.util.ArrayList.writeObject(ArrayList.java:570)
            at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
            at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
            at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
            at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
            at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:416)
            at net.sf.ehcache.Element.writeObject(Element.java:787)
            at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
            at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
            at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
            at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
            at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97)
            at net.sf.ehcache.store.compound.factories.DiskStorageFactory.serializeElement(DiskStorageFactory.java:327)
            at net.sf.ehcache.store.compound.factories.DiskStorageFactory.write(DiskStorageFactory.java:306)
            at net.sf.ehcache.store.compound.factories.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:412)
            at net.sf.ehcache.store.compound.factories.DiskPersistentStorageFactory$PersistentDiskWriteTask.call(DiskPersistentStorageFactory.java:510)
            at net.sf.ehcache.store.compound.factories.DiskPersistentStorageFactory$IndexWriteTask.call(DiskPersistentStorageFactory.java:547)
            at net.sf.ehcache.store.compound.factories.DiskPersistentStorageFactory.unbind(DiskPersistentStorageFactory.java:246)
            at net.sf.ehcache.store.compound.CompoundStore.dispose(CompoundStore.jav[/code]
    

    a:249)

    By any chance we can handle this using EhCahce?

    our jvm heap size is fixed. we use - xms10M -xmx64M