Saturday, April 22, 2006

Getting rid of java.lang.OutOfMemoryError

Most JVMs allocate memory on the heap for almost everything, except for reflective data. That is put in a separate location which is a section of the heap that is reserved for permanent generation. This gets easily filled up when you dynamically load an unload classes, or have a large number of classes. Simply add the following options to the java executable and all worries will be gone:
-XX:PermSize=256M -XX:MaxPermSize=256M
The entire command looks like this:
java -server -Djava.awt.headless=true -Xms1024M -Xmx1024M -XX:PermSize=256M -XX:MaxPermSize=256M
Read This

No comments: