My understanding is that the PermGen (in some sense) holds the class code in memory. Often we have lots of jar files referenced our classpath. When a jar file is included in the classpath (say in the lib directory of tomcat), are all the classes of all those jars automatically loaded into the PermGen?
In a similar question, once a class of a jar file is used, does PermGen load all the classes in that jar file, or just the class that is used (and then later load the rest of the class files when necessary)?
This depends to some degree on the implementation of the classloader and the JVM – the Java Virtual Machine specification says this:
In practice, no sane implementation should automatically load everything in a JAR file just because one class in the file is loaded, let alone just because it’s on the classpath.