Serial icon indicating copy to clipboard operation
Serial copied to clipboard

I am getting ava.lang.OutOfMemoryError: Java heap space during the Serialization... any clues?

Open malikchagani opened this issue 3 years ago • 1 comments

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at com.twitter.serial.stream.bytebuffer.ByteBufferSerializerOutput.ensureCapacity(ByteBufferSerializerOutput.java:244) at com.twitter.serial.stream.bytebuffer.ByteBufferSerializerOutput.encodeString(ByteBufferSerializerOutput.java:264) at com.twitter.serial.stream.bytebuffer.ByteBufferSerializerOutput.writeString(ByteBufferSerializerOutput.java:152) at com.twitter.serial.stream.bytebuffer.ByteBufferSerializerOutput.writeString(ByteBufferSerializerOutput.java:33) at com.irteqa.db.model.TripData$TripDataSerializer.serializeObject(TripData.java:46) at com.irteqa.db.model.TripData$TripDataSerializer.serializeObject(TripData.java:31) at com.twitter.serial.serializer.ObjectSerializer.serialize(ObjectSerializer.java:68) at com.twitter.serial.serializer.CollectionSerializers.serializeList(CollectionSerializers.java:119) at com.twitter.serial.serializer.CollectionSerializers.access$000(CollectionSerializers.java:38) at com.twitter.serial.serializer.CollectionSerializers$1.serializeObject(CollectionSerializers.java:50) at com.twitter.serial.serializer.CollectionSerializers$1.serializeObject(CollectionSerializers.java:46) at com.twitter.serial.serializer.ObjectSerializer.serialize(ObjectSerializer.java:68) at com.twitter.serial.serializer.CollectionSerializers.serializeMap(CollectionSerializers.java:173) at com.twitter.serial.serializer.CollectionSerializers.access$400(CollectionSerializers.java:38) at com.twitter.serial.serializer.CollectionSerializers$3.serializeObject(CollectionSerializers.java:100) at com.twitter.serial.serializer.CollectionSerializers$3.serializeObject(CollectionSerializers.java:95) at com.twitter.serial.serializer.ObjectSerializer.serialize(ObjectSerializer.java:68) at com.twitter.serial.stream.SerializerOutput.writeObject(SerializerOutput.java:57)

malikchagani avatar May 07 '22 02:05 malikchagani

This is the following reasons java throws the OutOfMemoryError.

  1. Poor programming approach: The object could not be possible allocated in Heap memory. The application holds the many references of objects, Which preventing the object from being garbage collected.
  2. Leakage in Memory: because of poor Programming approach. The program is using a high amount of memory, Which leads to the OutOfMemory error.
  3. Excessive use of finalizers: If in an application, a class is having a finalize method, then objects of such type are not able to obtain their space at the time of Garbage Collection (GC), and after Garbage Collection, these objects are kept in a queue for finalization later.

AasheeshLikePanner avatar Apr 03 '23 17:04 AasheeshLikePanner