总之有如下的方法.
1. linux下使用 java -XX:+PrintFlagsFinal -version 2>&1 | grep MaxHeapSize
windows下使用 java -XX:+PrintFlagsFinal -version |findstr MaxHeapSize
2. 使用jconsole连接后查看
3. Runtime.getRuntime().maxMemory();
What is the default maximum heap size for Sun's JVM from Java SE 6?18
favorite6
What is the default maximum heap size for Sun's JVM from Java SE 6 (i.e. equivalent to setting -Xmx)?
Looks like for Java SE 5 with a server-class machine,
it'sSmaller of 1/4th of the physical memory or 1GB.
Bonus question: Looks like for IBM's JVM you can
ask itjava -verbose:sizes -versionCan you similarly ask Sun's JVM?
Edit:
I used Runtime.getRuntime().maxMemory to confirm min(physical memory/4, 1G), referenced in
Sun documentation.
java jvm memory-managementshare|
improve this questionedited
Aug 23 '12 at 6:56community wiki
4 revs, 2 users 94%dfrankowWhy is this community wiki? Do you expect that it should lead to a lot of discussion? –
danben May 26 '10 at 17:27I don't really know when community wiki is valuable, so it was an experiment. –
dfrankow May 27 '10 at 13:195 Answers
activeoldestvotes25accepted
java 1.6.0_21 or later, or so...
$ java -XX:+PrintFlagsFinal -version 2>&1 | grep MaxHeapSizeuintx MaxHeapSize := 12660904960 {product}It looks like the min(1G) has been removed.
share|
improve this answeranswered
Feb 9 '12 at 23:10community wiki
qmc8
One can ask with some Java code:
long maxBytes = Runtime.getRuntime().maxMemory();System.out.println("Max memory: " + maxBytes / 1024 / 1024 + "M");See
javadoc.
share|
improve this answeranswered
May 27 '10 at 13:25community wiki
dfrankow4
one way is if you have a jdk installed , in bin folder there is a utility called jconsole(even visualvm can be used). Launch it and connect to the relevant java process and you can see what are the heap size settings set and many other details
When running headless or cli only, jConsole can be used over lan, if you specify a port to connect on when starting the service in question.
share|
improve this answeredited
Aug 24 '11 at 16:44community wiki
Inv3r53it is headless, so no graphics capabilities. –
dfrankow May 27 '10 at 13:192
With JDK, You can also use jinfo to connect to the JVM and get the value for MaxHeapSize:
jinfo -flag MaxHeapSize
share|
improve this answeredited
Oct 18 '12 at 2:21community wiki
2 revs, 2 users 75%user17549620
As of JDK6U18 following are configurations for the Heap Size.
In the Client JVM, the default Java heap configuration has been modified to improve the performance of today's rich client applications. Initial and maximum heap sizes are larger and settings related to generational garbage collection are better tuned.
The default maximum heap size is half of the physical memory up to a physical memory size of 192 megabytes and otherwise one fourth of the physical memory up to a physical memory size of 1 gigabyte. For example, if your machine has 128 megabytes of physical memory, then the maximum heap size is 64 megabytes, and greater than or equal to 1 gigabyte of physical memory results in a maximum heap size of 256 megabytes. The maximum heap size is not actually used by the JVM unless your program creates enough objects to require it. A much smaller amount, termed the initial heap size, is allocated during JVM initialization. This amount is at least 8 megabytes and otherwise 1/64 of physical memory up to a physical memory size of 1 gigabyte.
Source :
http://www.oracle.com/technetwork/java/javase/6u18-142093.htmlshare|
improve this answeranswered
Mar 29 at 7:52community wiki
Jābir
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。