robbat2: (Default)
[personal profile] robbat2
ObjectOutputStream oos = new ObjectOutputStream(...);
...
write lots of objects to the ObjectOutputStream.
...

get OutOfMemory exception :-(.

ObjectOutputStream keeps a record of every object it has seen, and thus prevents the object from being garbage-collected, even when you ARE done with it.

(no subject)

Date: 2005-03-30 09:51 pm (UTC)
From: [identity profile] robbat2.livejournal.com
your assumptions are correct.

I've tried what you suggest, but the output that I get from it doesn't work with ObjectInputStream.

It expects a complete stream, and when you close the OutputStream, it writes a termination marker (and every after that gets ignored by the ObjectInputStream).

The hack I've taken up for the moment is to simply abuse the reset() function of ObjectInputStream after every N calls to write something. This really slows things down, but it's not production code, and speed isn't an issue for me.

May 2017

S M T W T F S
 123456
78910111213
141516171819 20
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags