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.
Frank Langelage - 21 Mar 2007 20:55 GMT
> I have a Java application running on Soliaris. When I use the top
> command, I can see this:
[quoted text clipped - 16 lines]
> 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.
threasher - 22 Mar 2007 03:43 GMT
> > I have a Java application running on Soliaris. When I use the top
> > command, I can see this:
[quoted text clipped - 23 lines]
>
> - 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.
Lew - 22 Mar 2007 06:07 GMT
> 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