If you are facing following exception while running your code:
Exception in thread "main" java.lang.OutOfMemoryError: PermGen space
Default size of most of JVM Perm Space is around 64MB, it can easily ran out of memory if you have too many classes or huge number of Strings in your application. Even it doesn't depends on Xmx value so no matter how big your total heap size you can ran OutOfMemory in perm space.
Hence in order to fix this you can specify size of permanent generation using JVM options "-XX:PermSize" and "-XX:MaxPermSize" based on your project need.
For example,
-Xms128m -Xmx512m -XX:MaxPermSize=512m
The settings start the Java virtual machine with a minimum heap memory of 128M, a max heap size of 512M and a max perm gen size of 512M.
You can set this in Computer Environment Variable as shown in below image:
0 Comment(s)