How do you determine a good MaxPermSize?
                    
            I know I'll probably get beat up for not knowing my JVM Turning parameters. I admit that I should know them better than I do. Hopefully this post will help us all understand them a bit better.
Ever since I upgraded appfuse.org to AppFuse 1.9.1, it's been experiencing OOM issues.  They've been so bad that the site is lucky if it stays up for more than an hour.  I've done a fair amount of performance testing on a single AppFuse application (and gotten very good numbers), so I was pretty puzzled by the whole situation. 
To reproduce the problem, I downloaded all 5 demos to my machine and began profiling with JProfiler.  Nothing stood out, but I was able to reproduce the problem by clicking through all the different applications. While testing, I had my JAVA_OPTS set to -Xms256M -Xmx384M.
After staring at JProfiler for hours, I gave up and sent my findings to the AppFuse mailing list. After going back and forth with several ideas, Sanjiv came up with the winner.
Did you try increasing the max perm size (-XX:MaxPermSize=256m)? Max Perm size is running out of memory and not necessarily the main memory. Class metadata stuff is placed in the perm memory (google for more details) and since we're using Spring, Hibernate and Tapestry which all use a lot of reflection, proxying etc, it's not surprising that max perm size is running out of memory.
Based on his advice, I added -XX:MaxPermSize=256m to my JAVA_OPTS, fired up JProfiler/Tomcat and began hammering my local instance with WAPT. 15 minutes later, with 20 simultaneous users, the heap and memory were humming along nicely with no issues. I made the change on appfuse.org and it's been up every since.
This experience has motivated me to start adding "-XX:MaxPermSize=256m" to all my JAVA_OPTS.  Is this a good idea?  If so, is 256m a good value to use?  If not, what's the best way to determine (or guess) the proper value for this setting?
                        











                        