Why doesn't it look like -Xms and -Xmx are doing anything to Java's memory usage in Windows?

java, jvm

Solution

The issue is you're looking at the default memory column shown in Task Manager, which is "Memory - Private Working Set." This doesn't reflect what is actually reserved for use.

In Task Manager, go to the View menu and choose Select Columns. Add the "Memory - Commit Size" column. You should see this column reflects the reserved heap size from Java. In my tests, it shows around 6.6GB committed for a commandline of -Xms6G.

Here is Microsoft's page that explains what each column means.

"Memory - Private Working Set: Subset of working set that specifically describes the amount of memory a process is using that cannot be shared by other processes."

"Memory - Commit Size: Amount of virtual memory that is reserved for use by a process."

Problem

I am running this version of Java: ``` java version "1.7.0_07" Java(TM) SE Runtime Environment (build 1.7.0_07-b11) Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode) ``` I am running this on a Windows 2008 R2 64-bit server on Amazon EC2, in an m1.large instance that has 7.5GB of memory. When I start my Java app, I am using this command line: ``` java -Xms6G -Xmx6G -server -jar start.jar ``` My intent is to have Java reserve 6GB for it's heap, so that when my application runs, it will be able to load its entire dataset into memory. However, when I start the app, I only see 1.3GB of memory used in Task Manager?

Original source