If you load 2 classes with custom classloader, the output of jmap -permstat shows 3 classes for this class loader: Attaching to process ID 25522, please wait... Debugger attached successfully. Client compiler detected. JVM version is 12.0-b01-fastdebug 586 intern Strings occupying 34032 bytes. finding class loader instances ..done. computing per loader stat ..done. please wait.. computing liveness.................................................done. class_loader classes bytes parent_loader alive? type <bootstrap> 317 891720 null live <internal> 0xadb72d18 0 0 null live sun/misc/Launcher$ExtClassLoader@0xb1c97550 0xadb82248 3 3208 0xadb7b320 live java/net/URLClassLoader@0xb1c972a8 0xadb7b320 11 74328 0xadb72d18 live sun/misc/Launcher$AppClassLoader@0xb1ce0610 total = 4 331 969256 N/A alive=4, dead=0 N/A === import java.net.*; import java.io.*; public class ClassLoading { public static void main(String[] args) throws Exception { String dir = new File(".").getCanonicalPath(); URLClassLoader loader = new URLClassLoader(new URL[] { new URL("file://" + dir + "/a.jar") }); Class a = loader.loadClass("A"); Class b = loader.loadClass("B"); Thread.sleep(10000000); } } ===
|