I have a large-ish Spray API written with about 60-70 endpoints, and I run it using the spray-can HTTP server on Java 7. While running a large number of automated end-to-end tests against it, I received a java.lang.OutOfMemoryError: PermGen space error.
I have managed to deal with the problem by forcing classes to be unloaded (using -XX:+CMSClassUnloadingEnabled), increasing the Max PermGen size to 1024m and setting the thread stack size to 2m. But I'm worried I'm masking my problems.
My questions are:
I thought the PermGen stored class metadata. I can understand how I might run out of PermGen space when compiling the code. But in this case, I didn't compile the code on the machine, and this error hit me a few minutes into running the application as mentioned above. Why?
Am I taking the right approach to deal with PermGen space errors? Are there recommended JVM flags for apps run using Spray-Can?
When using the CMSClassUnloadingEnabled, do I also need to use UseConcMarkSweepGC in Java 7? This question (CMSPermGenSweepingEnabled vs CMSClassUnloadingEnabled) appears to indicate it applies to Java 6.