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

Could URLJarFile release memory held on to by the ZipFile after some time?

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      When looking at heap dumps I notice many byte[] objects being held on to by ZipFile within URLJarFile

      for example:
      byte[]#104406 : 2,055,296 items
      <references>
      ->cen in java.util.zip.ZipFile$Source#1111
      -->zsrc in java.util.zip.ZipFile$CleanableResource$FinalizableResource#564
      --->res in sun.net.www.protocol.jar.URLJarFile#565 : /blah.war-_kg-any-14.dir/webapp/WEB-INF/lib/admin-api-client-swagger-generated-15.22.0-2...

      Under the case of a long running apps it is the case that the likely hood that a class loader is going to need to load another class becomes lower and lower (or at least it is the case for me).

      I propose that Java support a way in which Java developers can configure the class loader to release the byte[] held by ZipFile after some time/memory constraints and re-open/fetch that data from the zip file when the class loader is asked to load another class.

      In my case I don't want to be wasting memory or data needed for a ZipFile within the class loader for jar files which I am very unlikely to load more classes from.


            lancea Lance Andersen
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: