0

I am starting the Java process with the following command:

java -Xmx32m -jar winstone-lite.jar --warfile=myWarFile.war

Instead of using the amount of memory I specified, it is still allocating 144m.

EDIT: When I say allocate, I mean when I look at the "top" process I am seeing 144m as the amount of memory being used.

I am using http://www.oracle.com/technetwork/java/embedded/documentation/index.html current version.

I would figure that if my application required more memory than I am allocating the jvm would crash.

1 Answers1

3

-Xmxjust tells the JVM how much memory it may use for its internal heap.

The JVM needs memory for other purposes (permanent generation, temporary space etc.), plus like every binary it needs space for its own binary code, plus any libraries/DLLs/.so it loads.

The 144 MiB you quote probably contains at least some of these other memory uses.

How did you measure the memory usage? On modern OS using virtual memory, measuring memory usage of a process is not quite trivial, and cannot be expressed as a single value.

sleske
  • 81,358
  • 34
  • 189
  • 227
  • I am obtaining the 144m from the top command. The OS is ubuntu. –  Nov 22 '10 at 16:40
  • @predhme: The values shown by top may include shared libraries etc., so they will always be much larger than just the heap. – sleske Nov 22 '10 at 21:08
  • Would it be fair to say then, comparing the amount reported by TOP and then the value reported by windows task manager is not accurate? Especially since they have 2 separate JVMS? –  Nov 23 '10 at 16:19
  • Yes, you have too many different variables, a comparison would be very difficult. – sleske Nov 23 '10 at 23:06