[compression] must call .end() on Inflater/Deflater
Eivind Larsen
Branch: esiqveland/jose4j:bugfix_memory_leak
Branch: b_c/jose4j:master
Merged
Merged pull request
Merged in esiqveland/jose4j/bugfix_memory_leak (pull request #11)
Merged in esiqveland/jose4j/bugfix_memory_leak (pull request #11)
This fixes memory leak in compression for jose4j.
When providing an Inflater/Deflater to a *OutputStream, it is the callers responsibility to cleanup after use.
When created, Inflater/Deflater calls into zlib and allocates a small amount of memory, which will only get released after .end() is called. This memory is off-heap, allocated in a C-library, so it will not show up in the JVM, making for a subtle increase over time.
Our service was gradully accumulating memory. Over 3 days it would consume 80GB of memory, with the JVM heap only at ~4GB. I tracked it down to this library by looking at the strings found in the heap dump looking like jwt strings.
With this change, the service has now been running 2 days and still at 5GB memory total.