Few days back I was reading one of the article of my all time favorite guru(Jaysen sharma), So I would like to share that in this article.
In case of OutOfMemoryError in PermGen Sapace …increasing only the Heap Size will not solve anything…
(OS Level)Process Size = Java Heap Native Space (2-3% OS related Memory)
PermSize : It’s a Native Memory Area Outside of the Heap, Where ClassLoading kind of things happens…. In an operating System like Windows Default Process Size is 2GB (2048MB) default (It doesn’t matter How much RAM do u have 2GB or 4GB or more)…until we don’t change it by setting OS level parameter to increase the process size..Usually in OS like Solaris/Linux we get 4GB process size as well.
Now Lets take the default Process Size=2GB (Windows), Now if you have set the -Xmx512M, we can assume that rest of the memory 1536 Mb is available for Native codes.
(ProcessSize HeapSize) = Native (2-3% OS related Memory)
2048 MB 512 MB = 1536 MB
MaxPermSize = (Xmx/3) —- Very Special Cases (One Third of maximum Heap Size)
MaxPermSize = (Xmx/4) —- Recommended (One Fourth Of maximum Heap Size)
So finally you need to increase the PermGen Size… like -Xmx1024m -Xms1024m -XX:MaxPermSize256m
But again these are not the Final values … It depends on ther Environments