... if I can reduce the PermGen space needed, for example, one ClassLoader per activity to allow class unloading.
Yes, the only way classes can be unloaded is if the Classloader loader is used, it is garbage collection. This means that references to each individual class and to the class loader must be zero.
How big is your PermGen? You can leave just by bumping into PermGen:
-XX:MaxPermGen=256m
on the command line. It is not uncommon to set it to 512 m. If you want a truly reliable solution, you will need to go the way of using a custom class loader for "activity". To help with debugging, add the following explanatory argument to your command line:
-XX:+TraceClassLoading
This will print the classes as they are loaded into the JVM on the command line.
source share