The following code is causing a OutOfMemmoryError: heap space for some 3 million rows.
Memory allocated to JVM is 4 GB, using 64 bit installation.
Is objOS an ObjectOutputStream?
If so, then that's your problem: An ObjectOutputStream keeps a strong reference to every object that was ever written to it in order to avoid writing the same object twice (it will simply write a reference saying "that object that I wrote before with id x").
This means that you're effectively leaking all ArrayList istances.
You can reset that "cache" by calling reset() on your ObjectOutputStream. Since you don't seem to be making use of that cache between writeObject calls anyway, you could call reset() directly after the writeObject() call.