title: A lot of java.util.zip.ZipFile$ZipFileInputStream objects/ Same jars loaded multiple times
body: <p>I am checking a heap dump of an Tomcat application which tends to crash when it has increased load right after startup. During the crash I observe an increasing number of unsuccessful attempts to perform <code>full GC</code> (6GB max heap size, using <code>CMS</code>) and <code>increased thread count</code> (ranging from 600 to 2000). MAT reports:</p>
  
  <pre><code>One instance of "java.lang.ref.Finalizer" loaded by "&lt;system class loader&gt;" occupies 
  5 291 528 160 (94,59%) bytes. The instance is referenced
  by org.python.core.ThreadState @ 0x679fba460 , loaded
  by "org.apache.catalina.loader.ParallelWebappClassLoader @ 0x674d08e88".
  The memory is accumulated in one instance of "java.lang.ref.Finalizer" loaded
  by "&lt;system class loader&gt;".
  
  Keywords
  java.lang.ref.Finalizer
  org.apache.catalina.loader.ParallelWebappClassLoader @ 0x674d08e88
  </code></pre>
  
  <p>Classes and amount of objects refered by <code>java.lang.ref.Finalizer</code>:</p>
  
  <pre><code> ...
   302 org.geoserver.platform.resource.FileSystemResourceStore$FileSystemResource$1
   406 java.net.SocksSocketImpl
   1519 java.util.jar.JarFile
   2075 java.util.zip.Deflater
   2086 org.geotools.map.MapContent
   2094 java.util.Timer$1
   2138 org.geoserver.wms.WMSMapContent
   2328 org.geotools.jdbc.JDBCFeatureReader
   2767 sun.net.www.protocol.jar.URLJarFile
   4106 javax.media.jai.WritableRenderedImageAdapter
   4724 org.geotools.map.FeatureLayer
   5801 java.io.FileInputStream
   8045 java.util.zip.Inflater
  24981 java.util.zip.ZipFile$ZipFileInflaterInputStream
  26772 java.util.zip.ZipFile$ZipFileInputStream
  </code></pre>
  
  <p>Files reffered by <code>java.util.zip.ZipFile$ZipFileInputStream</code>:</p>
  
  <pre><code>  ...
    339 /usr/local/tomcat8/webapps/my-server/WEB-INF/lib/gt-metadata-9.4.jar
    345 /usr/local/tomcat8/webapps/my-server/WEB-INF/lib/hsqldb-1.8.0.10.jar
    388 /usr/local/tomcat8/webapps/my-server/WEB-INF/lib/javassist.jar
    396 /usr/local/tomcat8/lib/orai18n-servlet.jar
    427 /usr/lib/jvm/jdk1.8.0_112/jre/lib/ext/sunjce_provider.jar
    448 /usr/local/tomcat8/webapps/my-server/WEB-INF/lib/xstream-1.4.2.jar
    449 /usr/local/tomcat8/webapps/my-server/WEB-INF/lib/jersey-core-1.17.jar
    474 /usr/local/tomcat8/lib/orai18n.jar
    538 /usr/local/tomcat8/webapps/my-server/WEB-INF/lib/jersey-server-1.17.jar
    553 /usr/local/tomcat8/webapps/my-server/WEB-INF/lib/gt-referencing-9.4.jar
    591 /usr/local/tomcat8/webapps/my-server/WEB-INF/lib/jts-1.13.jar
    614 /usr/local/tomcat8/webapps/my-server/WEB-INF/lib/jackson-databind-2.1.4.jar
    679 /usr/local/tomcat8/webapps/my-server/WEB-INF/lib/gt-opengis-9.4.jar
    688 /usr/local/tomcat8/webapps/geoserver/WEB-INF/lib/gt-xsd-gml3-15.2.jar
    908 /usr/local/tomcat8/webapps/my-server/WEB-INF/lib/jai-core-1.1.3.jar
   1023 /usr/local/tomcat8/webapps/my-server/WEB-INF/lib/gt-main-9.4.jar
   1161 /usr/local/tomcat8/webapps/my-server/WEB-INF/lib/ojdbc6.jar
   1194 /usr/local/tomcat8/lib/orai18n-translation.jar
   1688 /usr/lib/jvm/jdk1.8.0_112/jre/lib/rt.jar
   6631 /usr/local/tomcat8/lib/ojdbc6.jar
  </code></pre>
  
  <p>It seems strange to me that <code>jar</code> files are being loaded multiple times. I would suspect memory leak but since even <code>jdk1.8.0_112/jre/lib/rt.jar</code> is loaded 1000+ times I do not know what to think. <strong>So I am looking for an explanation why Java loads same jar files multiple times</strong>. Maybe there is a flag to control this process and I could improve Tomcat's performance that way. </p>