Everyone who has encountered this problem for the first time have certainly been tearing their hair. Why the Java process he complains of not having memory so it does not use half of that allocated to it?
The first part of the answer is pretty simple ... if you have already seen! Sun JVM defines the size of the allocated memory into two separate lots.
The conventional memory ("heap") typically configured with the options-Xms128m and-Xmx256m, respectively for the initial size and maxim
The memory of the "permanent generation", including statements containing Class objects (but not instances!) And Method. The size of this space is defined by the-XX: PermSize = 96m and-XX: MaxPermSize = 128m respectively to the initial size and maximum size
It is quite possible that the default setting (64MB maximum size) is insufficient and that an "OutOfMemoryError: PermGen space" appears after a few minutes of using the application, following the compilation of a volume too important to JSP. In this case, increase the space "permanent generation" to 128Mb should solve the problem. Beware though, as all options starting with XX, it is implementation-specific parameters of the JVM, namely that of Sun. Thus the BEA JVM instance does not separate the definition of these two spaces in its JVM options.
So, with these options we are rid of this memory error. Not necessarily ...
Indeed, it is possible that this error reappears after several eg re-deployment of a web application under Tomcat. In this case, setting the memory is not involved, but it is actually a memory leak. Specifically, the application classes that have been discharged are not recycled by the JVM. Indeed, as a reference to a class remains loaded by the classloader of the web application, this class loader and all the classes it has defined can not be recycled.
A multitude of causes can lead to this problem, the most classic:
For more information on this subject and in particular a list of tools to identify the source of the problem, I recommend this article .
. . . → Read more: "OutOfMemoryError: PermGen space" késaco?