I have a Java class that does something like this:
public void slowsDownOverTime() {
for (int i=0 ; i<nIter ; i++) {
BigObject bigObject = new BigObject();
// some code here that populates big object ...
CustomSerializer.write(bigObject);
}
}
What I observe is that as the code iterates, the time needed by the serializer to write gets longer and longer. When it starts, the serializer runs in milliseconds; after a few tens of thousands of iterations, it takes several seconds to run.
The disk to which the serializer writes is nowhere near full, and the Java heap space in use is nowhere near its maximum when this happens.
To the extent possible I've reduced the number and size of objects created and destroyed during this cycle. That basically exhausts my toolkit for addressing this sort of problem!
Any suggestions for how I understand and correct the gradual performance degradation would be greatly appreciated!