Skip to content

Commit

Permalink
Close Dictionary after every execution to avoid any memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
mgodwan committed Aug 16, 2023
1 parent 3a7c95a commit f0d1079
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,13 @@ private void compress(byte[] bytes, int offset, int length, DataOutput out) thro

// dictionary compression first
doCompress(bytes, offset, dictLength, cctx, out);
cctx.loadDict(new ZstdDictCompress(bytes, offset, dictLength, compressionLevel));
try (ZstdDictCompress dictCompress = new ZstdDictCompress(bytes, offset, dictLength, compressionLevel)) {
cctx.loadDict(dictCompress);

for (int start = offset + dictLength; start < end; start += blockLength) {
int l = Math.min(blockLength, end - start);
doCompress(bytes, start, l, cctx, out);
for (int start = offset + dictLength; start < end; start += blockLength) {
int l = Math.min(blockLength, end - start);
doCompress(bytes, start, l, cctx, out);
}
}
}
}
Expand Down

0 comments on commit f0d1079

Please sign in to comment.