apache / datasketches-java

A software library of stochastic streaming algorithms, a.k.a. sketches.
https://datasketches.apache.org
Apache License 2.0
875 stars 207 forks source link

Fix memory leak. #545

Closed leerho closed 2 months ago

leerho commented 2 months ago

The WritableMemory.allocateDirect returns a WritableHandle that implements AutoCloseable. And just as in C, when you malloc memory you are responsible to release that memory. In this case it is done with a try-with-resources block. As you will see in the fix.