File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes Outofmemory Error in ObjectInputStream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Outofmemory Error in ObjectInputStream" Watch "Outofmemory Error in ObjectInputStream" New topic
Author

Outofmemory Error in ObjectInputStream

Velmurugan Krishnan
Greenhorn

Joined: Jul 27, 2010
Posts: 2
Hi all

In our application we are Serializing the Object from one process (JVM) and deserializing the same Object from another process(JVM). Both serialization and deserialization will happen concurrently from Different JVM.

We are often getting OOM while de-serialization of the Object. We are using jdk 1.4 for compilation and Jre 1.6 for Running the JVM.

We have allocated 512Mb for the Process which is doing the deserialization. We have analyzed the hprof file is just 50Mb, JVM is not dumping the 512Mb.

We have googled about this OOM and suspecting that ObjectinputStream is leaking the Memory

is it a defect in ObjectInputStream ?

Could any one help us on this ?

The stack trace is

Exception in thread "Thread-9" java.lang.OutOfMemoryError: Java heap space
at java.lang.reflect.Array.newArray(Native Method)
at java.lang.reflect.Array.newInstance(Array.java:52)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1631)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
at java.io.ObjectInputStream.access$300(ObjectInputStream.java:188)
at java.io.ObjectInputStream$GetFieldImpl.readFields(ObjectInputStream.java:2109)
at java.io.ObjectInputStream.readFields(ObjectInputStream.java:519)
at java.lang.StringBuffer.readObject(StringBuffer.java:625)
at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at java.util.Hashtable.readObject(Hashtable.java:859)
at sun.reflect.GeneratedMethodAccessor82.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)




Thanks
Velmurugan
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

This is suggesting to periodically call reset().


[My Blog]
All roads lead to JavaRanch
Velmurugan Krishnan
Greenhorn

Joined: Jul 27, 2010
Posts: 2
Hi

Thanks a lot for your reply,

The serialization happens in different JVM with respect to de-serialization.

Moreover, we are calling the reset of ObjectOutputStream while doing the Serialization.



How can we prevent the OOM at de-serialization at this JVM ? what could be the root cause for this OOM ?

Thanks
Velmurugan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Outofmemory Error in ObjectInputStream