Skip to content

Close source stream in DefaultRPBuilder.getSourceData - #295

Merged
Patbox merged 1 commit into
Patbox:dev/26.3from
oiipo:fix/close-source-stream
Nov 3, 2026
Merged

Patbox merged 1 commit into
Patbox:dev/26.3from
oiipo:fix/close-source-stream

Conversation

@oiipo

@oiipo oiipo commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #294

getSourceData read the stream returned by getSourceStream without closing it. Those streams come from Files.newInputStream on jar zip filesystems, which keep each open entry stream and its native Inflater reachable until closed, so every getDataOrSource fallback leaked native memory for the lifetime of the server.

The stream is now opened in a try-with-resources. Behavior is otherwise unchanged: a missing source still returns null, and failures are still logged by the existing catch.

Tested on 0.17.5+26.2 with the same change applied: live Inflater instances after resource pack generation went from 188,497 to 226, and process commit from 9.7 GB to 1.4 GB. The same code is present on dev/26.2.

@Patbox
Patbox merged commit ca0fd4e into Patbox:dev/26.3 Nov 3, 2026
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.

DefaultRPBuilder.getSourceData never closes its source InputStream (native memory leak)

2 participants