To know the default JVM memory that is allocated in the system memory using the java program see this program. In java itself is provide one the class called Runtime and access those class using the methods in its own class after that changing the JVM heap memory you will see .
It will give the memory in terms of bytes.
In java by default JVM will occupy the memory in system is 64MB If we want to set the memory of the JVM memory upto 1024MB. To explicitly allocate the memory for JVM in java by using the command. If we get an Exception called OutOfMemoryError :PerGen then we have to allocate more memory to the Java Virtual Machine by using the command -XX:PermSize=64 -XX:MaxPermSize=128M .
Ex: java -XX:PermSize=64M -XX:MaxPermSize=128M
If we get an exception called OutOfMemoryError : Java Heap Space then we have to allocate memory to the Java virtual Machine heap memory by using the -xms javaApp
EX: java -Xms512M
package com.test; public class JVMTest { public static void main(String[] args) { Runtime runtime = Runtime.getRuntime(); System.out.println("max memroy"+runtime.maxMemory()); System.out.println("Total memeoy "+runtime.totalMemory()); } }
In java by default JVM will occupy the memory in system is 64MB If we want to set the memory of the JVM memory upto 1024MB. To explicitly allocate the memory for JVM in java by using the command. If we get an Exception called OutOfMemoryError :PerGen then we have to allocate more memory to the Java Virtual Machine by using the command -XX:PermSize=64 -XX:MaxPermSize=128M .
Ex: java -XX:PermSize=64M -XX:MaxPermSize=128M
If we get an exception called OutOfMemoryError : Java Heap Space then we have to allocate memory to the Java virtual Machine heap memory by using the -xms
EX: java -Xms512M
Comments
Post a Comment