Wednesday, 8 January 2014

Increase heap size in JVM( Permgen space error in Tomcat).

To read JVM heap size. 
The maximum theoretical heap limit for the 32-bit JVM is 4G. Due to 
various additional constraints such as available swap, kernel address 
space usage, memory fragmentation, and VM overhead, in practice the 
limit can be much lower. On most modern 32-bit Windows systems the 
maximum heap size will range from 1.4G to 1.6G. On 32-bit Solaris 
kernels the address space is limited to 2G. On 64-bit operating systems 
running the 32-bit VM, the max heap size can be higher, approaching 4G 
on many Solaris systems.
 
public class GetHeapSize {
 public static void main(String[]args){
  
  //Get the jvm heap size.
  long heapSize = Runtime.getRuntime().totalMemory();
  
  //Print the jvm heap size.
  System.out.println("Heap Size = " + heapSize);
 }
}
 
 
Good url to gain knowledge on memory 
http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#gc_heap_32bit 
 
Update the tomcat\bin\catalina.bat file.
SET JAVA_OPTS="-Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m 
-XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m 
-XX:MaxPermSize=256m -XX:+DisableExplicitGC”
  

No comments: