Java Memory Question

T

threasher

I have a Java application running on Soliaris. When I use the top
command, I can see this:

PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND
29042 ownecx 17 29 10 81M 29M sleep 0:11 14.74% java

The value SIZE is always 81M, and RES is 29M.

When I added -Xmx1K to the application, I thought the application
would throw OutOfMemoryError due to insufficient heap space. But it
didn't, and it still runs fine, and using top command shows that SIZE
is still 81M and RES is still 29M. How can that be? In fact, whatever
value I give for -Xmx does not seem to make any difference at all.

Then I wrote a really simple program with just a couple of lines to
take up some memory. This time, when I play around with -Xmx, it does
throw OutOfMemoryError if the value is too low.

So how come that application is so special? The -Xmx does not make a
difference at all.
 
F

Frank Langelage

threasher said:
I have a Java application running on Soliaris. When I use the top
command, I can see this:

PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND
29042 ownecx 17 29 10 81M 29M sleep 0:11 14.74% java

The value SIZE is always 81M, and RES is 29M.

When I added -Xmx1K to the application, I thought the application
would throw OutOfMemoryError due to insufficient heap space. But it
didn't, and it still runs fine, and using top command shows that SIZE
is still 81M and RES is still 29M. How can that be? In fact, whatever
value I give for -Xmx does not seem to make any difference at all.

Then I wrote a really simple program with just a couple of lines to
take up some memory. This time, when I play around with -Xmx, it does
throw OutOfMemoryError if the value is too low.

So how come that application is so special? The -Xmx does not make a
difference at all.

You possible did it the wrong way for the application, it seems to not
come through.
With "jps -v 29042" you get the full command line or use pargs 29042 to
see that this option is not there.
 
T

threasher

You possible did it the wrong way for the application, it seems to not
come through.
With "jps -v 29042" you get the full command line or use pargs 29042 to
see that this option is not there.- Hide quoted text -

- Show quoted text -

The application was started like this:

java -Xms4M - Xmx8M com.mycompany.myproject.MyClass

But whichever values I give for -Xms and -Xmx, the top command will
always show that SIZE is around 85M and RES is around 30M.
 
L

Lew

threasher said:
The application was started like this:

java -Xms4M - Xmx8M com.mycompany.myproject.MyClass

But whichever values I give for -Xms and -Xmx, the top command will
always show that SIZE is around 85M and RES is around 30M.

The -Xms and -Xmx parameters specify Java heap size, not overall 'java'
application size as seen by the OS. Heap is a managed resource within the JVM;
there is still a memory requirement for the JVM itself, for class definitions,
literal constant pools, ...

-- Lew
 

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,780
Messages
2,569,611
Members
45,281
Latest member
Pedroaciny

Latest Threads

Top