Why is OutOfMemoryError thrown after writing a large number of objects into an ObjectOutputStream?
The ObjectOutputStream maintains a table mapping objects written into the stream to a handle. The first time an object is written to a stream, its contents are written into the stream; subsequent writes of the object result in a handle to the object being written into the stream. This table maintains references to objects that might otherwise be unreachable by an application, thus, resulting in an unexpected situation of running out of memory. A call to the ObjectOutputStream.reset() method resets the object/handle table to its initial state, allowing all previously written objects to be elgible for garbage collection. See handle.
Related Questions
- If the BRMS Application Client stores several objects as a large file on TSM servers, can I still recover single objects?
- How can I modify a serialized object which is stored in a file if the file contains a large number of objects?
- TOAD is taking a long time to load a large number of objects. What can I do about it?