luben / zstd-jni

JNI binding for Zstd
Other
853 stars 168 forks source link

Fix missing native free of Dict #309

Closed mortengrouleff closed 5 months ago

mortengrouleff commented 5 months ago

Even when using a by-reference buffer, the dict struct itself is malloc'ed and thus needs freeing to not leak memory.

The leak is fairly slow, as it leaks the size of the struct ZSTD_CDict_s (and ZSTD_DDict_s for decompress) on every use, which takes quite a few rounds to become visible as an increase in overall process size.

The issue affects exclusively uses of the (new in v1.5.6-2) getByReferenceBuffer variants. I would like to request a version bump and a new published build to allow using this downstream.

Fixes: https://github.com/luben/zstd-jni/issues/310

codecov[bot] commented 5 months ago

Codecov Report

Merging #309 (cde5f8f) into master (c76455c) will decrease coverage by 0.17%. Report is 5 commits behind head on master. The diff coverage is 100.00%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #309 +/- ## ============================================ - Coverage 60.01% 59.85% -0.17% - Complexity 308 311 +3 ============================================ Files 26 26 Lines 1473 1487 +14 Branches 170 174 +4 ============================================ + Hits 884 890 +6 - Misses 434 441 +7 - Partials 155 156 +1 ```
mortengrouleff commented 5 months ago

Codecov Report

Merging #309 (cde5f8f) into master (c76455c) will decrease coverage by 0.17%.

Gotta love how removing code results in lowered coverage...

luben commented 5 months ago

Thanks! Merging it

luben commented 5 months ago

less code that was covered increased the share of uncovered code, and there is some :)

Just published 1.5.6-3 with that fix