When your Java application ends it prints information like
JVMSHRC168I Total shared class bytes read=78435794. Total bytes stored=522418
JVMSHRC818I Total unstored bytes due to the setting of shared cache soft max is 0. Unstored AOT bytes due to the setting of -Xscmaxaot is o.
Unstored JIT bytes due to the setting of -Xscmaxjitdata is 0.
So you can see what amount of space is used.
Displaying activity as Java starts
-Xshareclasses:verboseIO,…
For example
-Xshareclasses:verboseIO,verbose,name=zoweGW,cacheDirPerm=0777,cacheDir=/u/tmp/zowec/"
This produces output like
Entries which were found and used
Found class java/lang/Object in shared cache for class-loader id 0.
Found class java/lang/J9VMInternals in shared cache for class-loader id 0.
Entries which were not found…but added.
The following shows that the entry was not found in the share classes cache, but was added successfully. Next time this would give ” found and used” above.
Failed to find class java/security/Guard in shared cache for class-loader id 0.
Stored class java/security/Guard in shared cache for class-loader id 0 with
URL /Z31B/usr/lpp/java/J8.0_64/J21.0_64/lib/modules (index 0).
What classes were not found and not added?
Failed to find class org/yaml/snakeyaml/constructor/Construct in shared cache for class-loader id 0.
Failed to find class org/yaml/snakeyaml/constructor/Construct in shared cache for class-loader id 2.
When Java option -verbose:class was enabled, there was additional information
class load: org.yaml.snakeyaml.constructor.Construct from:
jar:nested:/u/tmp/zowep/components/gateway/bin/gateway-service.jar/!BOOT-INF/lib/snakeyaml-2.2.jar!/
The jar:nested means it is a jar within a bigger jar. The shared class support does not support this.
To exploit the shared classes function it seems to be better to have individual .jar files rather than one large jar file with lots of jar files within it.
The loader id 2 is from the spring framework loaded. This loads the nested jar files.
What classes were loaded from where?
With the Java option -verbose:class (not a shared classes cache option) this reports on classes used.
class load: java/net/URLClassLoader$SharedClassMetaDataCache from: jrt:/java.base
class load: java/net/URLClassLoader$SharedClassMetaData from: jrt:/java.base
What’s in the shared cache?
-Xshareclasses:…,printStats
Use the printStats command
/usr/lpp/java/J21.0_64/bin/java -Xshareclasses:cacheDir=/u/tmp/zowec,name=zoweGW,printStats,
to display a summary of the cache
cache layer = 0
cache size = 83885520
softmx bytes = 83885520
free bytes = 31274608
Reserved space for AOT bytes = -1
Maximum space for AOT bytes = -1
Reserved space for JIT data bytes = -1
Maximum space for JIT data bytes = 31457280
Metadata bytes = 752058
Metadata % used = 1%
Class debug area size = 6680576
Class debug area used bytes = 5576890
Class debug area % used = 83%
ROMClass bytes = 35210448
AOT bytes = 8456750
JIT data bytes = 1150472
Zip cache bytes = 0
Startup hint bytes = 240
Data bytes = 360368
# ROMClasses = 14554
# AOT Methods = 3510
# Classpaths = 2
# URLs = 0
# Tokens = 0
# Zip caches = 0
# Startup hints = 2
# Stale classes = 0
% Stale classes = 0%
Cache is 62% full
Cache is accessible to current user = true
Class debug area % used. If this is close to 100% your cache is too small, you will need to destroy the cache, and make it bigger.
-Xshareclasses:…,printAllStats
The printAllStats command provides the information in printStats, and detailed information like
1: 0x000002003ADA0DB4 CLASSPATH
/Z31B/usr/lpp/java/J8.0_64/J21.0_64/lib/modules
1: 0x000002003ADA0D80 ROMCLASS: java/lang/Object at 0x00000200364581E0.
Index 0 in classpath 0x000002003ADA0DB4
ROMMETHOD: <init> Signature: ()V Address: 0x00000200364583D8
ROMMETHOD: clone Signature: ()Ljava/lang/Object; Address: 0x00000200364583F4
ROMMETHOD: equals Signature: (Ljava/lang/Object;)Z Address: 0x000002003645841C
ROMMETHOD: finalize Signature: ()V Address: 0x000002003645844C
ROMMETHOD: getClass Signature: ()Ljava/lang/Class; Address: 0x0000020036458484
ROMMETHOD: hashCode Signature: ()I Address: 0x00000200364584A0
ROMMETHOD: notify Signature: ()V Address: 0x00000200364584C0
ROMMETHOD: notifyAll Signature: ()V Address: 0x00000200364584D8
ROMMETHOD: toString Signature: ()Ljava/lang/String; Address: 0x00000200364584F0
ROMMETHOD: wait Signature: ()V Address: 0x000002003645852C
ROMMETHOD: wait Signature: (J)V Address: 0x0000020036458554
ROMMETHOD: wait Signature: (JI)V
This shows for class java/lang/Object coming from /Z31B/usr/lpp/java/J8.0_64/J21.0_64/lib/modules there were several methods.
One thought on “What’s happening with my Java shared classes?”