Timofey
Timofey

Reputation: 2508

Java: option -Xms is not applied immediately?

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

Upvotes: 1

Views: 1682

Answers (2)

eabrand
eabrand

Reputation: 226

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?

Upvotes: 0

Paul Tomblin
Paul Tomblin

Reputation: 182782

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

Upvotes: 2

Related Questions