if your java program requires a larg amount of memory , it is possible that the virttual machine will begin to throw OutOfMemoryError instances when
attempting instantiate and object the default heap size if 1 MB and can increase as much as 16 MB
=======Setting/Incrase JVM heap size================
it is possible to increase heap size allocated by the java virtual machine (JVM) by using command line option.
Following are few options available to change Heap Size.
-Xms
-Xmx
-Xss
For Example, you can set mininum heap to 64 MB and maximum heap 256 MB for a Java program helloWorld.
java -Xms64m -Xmx256m HelloWorld
t is possible to read the default JVM heap size programmatically by using totalMemory() method of Runtime class. Use following code to read JVM heap size.
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);
}
}
อ้างอิง : http://viralpatel.net/blogs/2009/01/jvm-java-increase-heap-size-setting-heap-size-jvm-heap.html
ไม่มีความคิดเห็น:
แสดงความคิดเห็น