What does -Xmx really do?

B

Brian

I invoked a java program with something like:

java -Xmx1600M myprogram

It ran for a day and now top reports this:
top - 17:14:09 up 1 day, 1:30, 5 users, load average: 5.56, 5.98, 6.13
Tasks: 143 total, 1 running, 142 sleeping, 0 stopped, 0 zombie
Cpu(s): 90.6% us, 9.2% sy, 0.0% ni, 0.0% id, 0.2% wa, 0.0% hi, 0.0% si
Mem: 2054672k total, 2037940k used, 16732k free, 1872k buffers
Swap: 2031608k total, 1015260k used, 1016348k free, 303348k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5689 brian 15 0 2887m 1.6g 1484 S 99.9 79.4 1680:00 java
^^^

Obviously 2887m >> 1600m. So what is Xmx really?
Maybe it's the amount of memory a program can use from the user
perspective, without the details of pointers, gc, etc. thrown in.

That's fine. But I still wanted my program to stop using memory
once it hit the swap space (even if it throws an error). Is there
a way to do this?

BTW, DDJ covered a story on Enerjy just recently. Some of the
profiling tools look interesting. Are there any other favorites?
I'm on a starving student budget by the way.

Thanks!
Brian
 
R

Roedy Green

That's fine. But I still wanted my program to stop using memory
once it hit the swap space (even if it throws an error). Is there
a way to do this?

In a multiuser system that makes no sense. Your allotment of real ram
varies drastically over the span of the run. You would never get
anything done if you were limited to your minimal allotment of real
ram.

You can experiment with changing the size of your virtual space.
Shrinking it causes more frequent GC and less swapping. Sometimes
shrinking the virtual can actually make a program faster by keeping it
more "local". Experiment with both shrinking and growing. The
optimal depends on what else in typically running and of course how
much RAM you bought.
 
T

Tor Iver Wilhelmsen

Brian said:
Obviously 2887m >> 1600m. So what is Xmx really?

Max HEAP memory. Your listing reports total process memory, perhaps
java.so + awt.so + ... + heap
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top