Closed overheadhunter closed 2 years ago
Did you considered the
Chunk
class implementingAutoclosable
?
The problem is that Chunk is passed around between classes a lot, i.e. try-with-resource can't be used. It is even cached, so analysis tools have a hard time tracking the lifecycle and will report false positive leaks.
Kudos, SonarCloud Quality Gate passed!
Previously, each chunk of data allocated a new 32kB ByteBuffer, which was in most cases very short-lived. This lead to both, massive allocations as well as garbage collection activity.
To reduce both memory as well as CPU pressure, this introduces a filesystem-scoped pooling mechanism. ByteBuffers should be returned to the pool but it will do no harm not to do so.