Skip to content

End the Inflater of ZIP PGPCompressedData streams on close() - #2581

Open
KubaJagiello wants to merge 1 commit into
bcgit:mainfrom
KubaJagiello:fix/pgp-compressed-data-inflater-end
Open

KubaJagiello wants to merge 1 commit into
bcgit:mainfrom
KubaJagiello:fix/pgp-compressed-data-inflater-end

Conversation

@KubaJagiello

@KubaJagiello KubaJagiello commented Nov 26, 2026 •

Copy link
Copy Markdown

Fixes #2580.

Overrides close() in the ZIP branch to call inf.end() after super.close(), as SafeDeflaterOutputStream does with def.end(). Covers both getDataStream() overloads.

Each stream holds roughly 23 KB of native zlib memory that the GC doesn't see, so under load it can build up between GCs. On JDK 25, 20,000 read/close cycles with GC deferred grew RSS by about 555 MB for ZIP against about 99 MB for ZLIB. With this fix ZIP drops to the same 99 MB.

No test included. Whether an Inflater has been ended isn't visible through the public API, so a test would need reflection plus --add-opens in pg/build.gradle. Happy to add one if you want it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PGPCompressedData.getDataStream() never ends the Inflater for ZIP data

1 participant