Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

What is the best way to verify default heap size in Java

941867Jun 6 2012 — edited Jun 6 2012
Hi All,
What is the best way to verify default heap size in Java ? does it vary over JVM to JVM . I was reading this article http://javarevisited.blogspot.sg/2011/05/java-heap-space-memory-size-jvm.html , and it says default size is 128 MB but When I run following code :

public static void main(String args[]) {
int MB = 1024*1024;
System.out.println(Runtime.getRuntime().totalMemory()/MB);
}

It print "870" i.e. 870 MB.

I am bit confused, what is the best way to verify default heap size in any JVM ?

Edited by: 938864 on Jun 5, 2012 11:16 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 4 2012
Added on Jun 6 2012
5 comments
551 views