Preconditions:
Can you rerun your tests with this option -XX:MaxDirectMemorySize=1024m
? The exact value of this limit does not matter, but it shows possible "leaks".
Can you also provide GC details (-XX:+PrintGC
)?
java.nio.ByteBuffer is a possible cause of them due to it specific finalization.
UPDATE #1
I have seen similar behavior for two another reasons: java.misc.Unsafe (unlikely) and high-loaded JNI-calls.
It is hard to understand without profile of the test.
UPDATE #2
Both high-loaded JNI-calls and finalize() method cause the described problem since objects do not have enough time to finalize.
The j.u.zip.Inflater
fragment below:
/**
* Closes the decompressor when garbage is collected.
*/
protected void finalize() {
end();
}
/**
* Closes the decompressor and discards any unprocessed input.
* This method should be called when the decompressor is no longer
* being used, but will also be called automatically by the finalize()
* method. Once this method is called, the behavior of the Inflater
* object is undefined.
*/
public void end() {
synchronized (zsRef) {
long addr = zsRef.address();
zsRef.clear();
if (addr != 0) {
end(addr);
buf = null;
}
}
}
private native static void end(long addr);