ZipEntryContext retention in JBoss EAP 5
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 5.x
Issue
- A heap dump shows significant retention due to many
org.jboss.virtual.plugins.context.zip.ZipEntryContext
objects. - With the
-Djboss.vfs.forceVfsJar=true
flag set, we see many org.jboss.virtual.plugins.context.jar.NestedJarHandler objects. - Following issue is seen on the heap dump
751 instances of "org.jboss.virtual.plugins.context.zip.ZipEntryContext", loaded by"org.jboss.bootstrap.NoAnnotationURLClassLoader @ 0xfffffffed0c02d00" occupy166,264,480 (13.73%) bytes.
Resolution
- A workaround is to reduce the number of deployed jars:
- Slim EAP 5.
- For applications that use the same library version, move any duplicate jars amongst deployments to
$JBOSS_HOME/server/$CONFIG/lib/
.
- use unzipped deployments
- use the below JVM option to re-order in-memory JAR handling to reduce VFS cache memory consumption at potential performance hit:
-Djboss.vfs.optimizeForMemory=true
The jboss.vfs.optimizeForMemory option causes JBossVFS to open the jar prior to and close it after each operation. The potential benefit is that it does not need to keep the zip metadata in memory between requests. The drawback is than reading the zip metadata for each request can be very expensive.
The potential benefit only sometimes help (and often does not), since reloading the metadata frequently adds garbage collection pressure, and if operations are frequent the transient memory used loading it is often higher than the memory saves between calls. Class files are only loaded once to initialise the class and possibly on startup for annotation scanning. The main problem comes from the loading of non-class resources, such as ServiceLoader service files (if the service is not cached), or library configuration files.
Root Cause
- VFSClassLoader is retaining ZipEntryContext/.NestedJarHandler instances for future loading of resources. This is by design so resources are not reloaded every classpath scan.
Diagnostic Steps
-
Check what JAR entries there are using the OQL statement below. Lots of duplication here will show you were the retention is stemming from.
SELECT toString(s.rootURI.string) FROM org.jboss.virtual.plugins.context.zip.ZipEntryContext s
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments