There's a pretty devilish memory leak
hidden in Java's serialization process that will affect you if you have any such streams that are long-lived (like a permanent network connection
or a log file
). In order to save space or bandwidth, the ObjectOutputStream keeps references to all objects that have been sent through it. If the same object is sent again, only a short reference to the previous instance is sent, instead of the whole object.
Of course this means that no object ever sent through the stream can be reclaimed by the garbage collection until the stream is closed - a classic memory leak. You can fix it by periodically calling the reset method of the stream, which will remove the references. But if you don't know this, good luck finding the reason for the leak...