Skip to content

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

Closed

Description

@oiipo

Version: polymer 0.17.5+26.2

DefaultRPBuilder.getSourceData(String) does getSourceStream(path).readAllBytes() without closing the stream, getSourceStream opens it with Files.newInputStream on a jar’s zip filesystem. The zip filesystem keeps every open entry stream, and its native zlib Inflater is reachable until it is closed so none of them get garbage collected

Every ResourcePackBuilder.getDataOrSource() call that falls back to a source jar leaks about 40 KB of native memory for the life of the server. Any mod that reads a lot of source assets during generation starts building up quickly;; there was a measured 188,497 live java.util.zip.Inflater / ZipFileSystem$EntryInputStream objects after a full GC, about 7.4 GB of native memory that NMT doesn’t track (process commit 9.7 GB, NMT total 2.4 GB) and this eventually crashed the JVM with “Native memory allocation (malloc) failed” error

With the stream closed, live Inflaters after generation dropped from 188,497 to 226 and process commit from 9.7 GB to 1.4 GB

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions