1

I execute the following command:

java -Xms1024M -Xmx1024M mypackage.MyClass

I expect that resources are captured by JVM immediately, but in fact my resource manager is showing that 7.2M was captured by JVM.

Does anybody know what is the reason?

PS: The documentation (man java) says about the option the following:

-Xmsn

Specify the initial size, in bytes, of the memory allocation pool. This value must be a multiple of 1024 greater than 1MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is chosen at runtime based on system configuration. For more information, see HotSpot Ergonomics Examples:

-Xms6291456

-Xms6144k

-Xms6m

EDIT:

java -version

returns:

java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8.1) (6b18-1.8.1-0ubuntu1~9.10.1)
OpenJDK Server VM (build 16.0-b13, mixed mode)

OS: 9.10 - the Karmic Koala

Timofey
  • 2,478
  • 3
  • 37
  • 53
  • The minimum size indicates to the JVM to allocate this size of memory freely. It still does some resource tidying but it will consume the amount of memory you give it fairly quickly given half a chance. However, it still won't allocate the memory until it has a use for it. Note: it will allocate virtual memory immediately. – Peter Lawrey Oct 06 '10 at 21:12

2 Answers2

2

Note that the documentation does NOT say that "G" is an allowed suffix. Try with 1024M instead of 1G.

Paul Tomblin
  • 179,021
  • 58
  • 319
  • 408
0

The heap size doesn't control how much memory is used, just how much resources are available and how much garbage collection needs to be completed. The VM can use less than or more than the max and min heap sizes. More information on how to find out your desired heap, look at this thread

how to choose the jvm heap size?

Community
  • 1
  • 1
eabrand
  • 226
  • 3
  • 6