Why is OutOfMemoryError thrown after writing a large number of objects into an ObjectOutputStream?

Why is OutOfMemoryError thrown after writing a large number of objects into an ObjectOutputStream?

When you write a large number of objects into an Object output stream, these objects might be unreachable by the reference that the reference table is hoding. If they are not garbage collected by the JVM, resulting the running out of memory error. A call to the ObjectOutputStream.reset() method resets the object/handle table to its initial state, allowing all previously written objects to be eligible for garbage collection. 

By:Jalees
Date:2016-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher