Exceeding -Xmx memory size

C

Chris

I'm seeing an odd phenomenon on my Linux box. I'm running a Java app that
seems to be consuming more memory than I have given it using the -Xmx
command line switch. The command line says -Xmx256m, but when I run the ps
command to see memory usage (ps -A -F), it says that virtual memory usage is
629mb (VSZ) and physical usage is 434mb (RSS).

How is this possible?

Suse Linux 9.1
Kernel 2.6.5-7.111.19-smp
Sun's JVM version 1.4.2_03
 
C

Chris Smith

I'm seeing an odd phenomenon on my Linux box. I'm running a Java app that
seems to be consuming more memory than I have given it using the -Xmx
command line switch. The command line says -Xmx256m, but when I run the ps
command to see memory usage (ps -A -F), it says that virtual memory usage is
629mb (VSZ) and physical usage is 434mb (RSS).

How is this possible?

The -Xmx option to the JVM specifies the maximum size of the Java
garbage collected heap. The size of the process reported by ps will
include that, plus any other memory used by the process. The following
are examples of things that are not part of the garbage collected heap
and yet are part of the memory required by the process:

- Code to implement the JVM
- The C manual heap for data structures implementing the JVM
- Stacks for all of the threads in the system (app + JVM)
- Cached Java bytecode (for libraries and the application)
- JITed machine code (for libraries and the application)
- Static variables of all loaded classes

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
C

Chris

The -Xmx option to the JVM specifies the maximum size of the Java
garbage collected heap. The size of the process reported by ps will
include that, plus any other memory used by the process. The following
are examples of things that are not part of the garbage collected heap
and yet are part of the memory required by the process:

- Code to implement the JVM
- The C manual heap for data structures implementing the JVM
- Stacks for all of the threads in the system (app + JVM)
- Cached Java bytecode (for libraries and the application)
- JITed machine code (for libraries and the application)
- Static variables of all loaded classes

Is is possible to specify an absolute upper bound on the memory consumed by
the entire process?
 
C

Chris Smith

Is is possible to specify an absolute upper bound on the memory consumed by
the entire process?

Well, man ulimit -v, since you seem to be on UNIX. That would need to
be run within the context of some parent shell whose sole purpose is to
run the application.

This is very posssibly a bad idea, though. The virtual memory size of a
process hardly matters with the current price levels for disk storage;
and the physical memory size may just mean that you don't have anything
else running that needs memory. Processes using memory isn't a bad
thing until you need that memory for something else. Operating systems
do a good job of allocating working sets to processes based on their
actual observed locality at runtime compared to other processes. Are
you sure you know better than your OS kernel? You might just be getting
in the way.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

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,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top