Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8156484

ZipFile retains too much native memory from caching Inflaters

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • tbd
    • 8
    • core-libs
    • None

      When a ZipFile creates an Inflater to read a compressed zip entry, the Inflater is retained in a cache for future uses. Each Inflater retains around 32kb of native memory in its zlib data structures. When this cache is in heavy use, such as when iterating through a compressed zip file with many small entries, this optimization is barely positive. For its intended use of speeding up class loading, it is not really noticeable. On the other hand, for modern Java applications with many small jar files, the retained memory is a serious problem. We see classpaths on the order of 10,000 jar files, each of which has a long lived ZipFile object, resulting in memory bloat on the order of 1GB.

      It's reasonable to remove the Inflater cache entirely, but it's also reasonable to have a small cache to make ZipFile iteration a wee bit faster. But native resource cleanup is always a headache.

            martin Martin Buchholz
            martin Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: