How is the max value that you can set with the -Xmx param for heap size of the java jvm determined?

C

cs5b

I would like to instantiate the java jvm with a larger max heap size.
I use the -Xmx parameter to do so. I have discovered though that the
value you can specify here differs from box to box. I assume its
related to the physical and swap memory. Is there a formula that can
be applied to determine the max value? Can you get around physical
memory limitations by instructing the jvm to utilize swap memory (I am
using linux)?
Cheers -
Christian
 
J

Juan Singh

I would like to instantiate the java jvm with a larger max heap size.
I use the -Xmx parameter to do so. I have discovered though that the
value you can specify here differs from box to box. I assume its
related to the physical and swap memory. Is there a formula that can
be applied to determine the max value? Can you get around physical
memory limitations by instructing the jvm to utilize swap memory (I am
using linux)?
Cheers -
Christian

On a 32-bit machine a process cannot get more than 2GB regardless of how
much physical memory you have on the machine.

-Xmx defines the Java heap size, which does not include the size for the
VM itself. From the OS perspective any java program will take
JavaHeapSize + VM Size. Therefore, I suggest that you never exceed 1.5
GB for java heap.

If the actual physical + virtual memory is less than 2GB on the machine,
then find out what else is running on the machine and then adjust the size.

Juan.
 
C

cs5b

Juan, thanks for your reply.

I do not want to exceed 2 gigs. I want to set something like 1.8 gigs.
however, as soon as I set above 1.5 gigs, it complains with an error
msg. I do have 2 gigs of ram (of which 1.5 gigs are free) and 2 gigs
of swap (of which all is free), so java, theoretically, should utilize
300mb of the swap with this setting. However, it doesnt, but just
bombs...
 
E

Eric Sosman

Juan Singh wrote On 02/02/07 15:54,:
On a 32-bit machine a process cannot get more than 2GB regardless of how
much physical memory you have on the machine.

That may be true of some systems, but surely not of all.
On the Solaris box I happen to be using at the moment I can
get to -Xmx3908m, about 90% of the full 4GB. Windows and
Linux and Mac and whatever may have different limits. (Yes,
Solaris is a 64-bit O/S. However, the JVM I used is a 32-bit
application, hence limited to no more than 4GB no matter what.
My point is that the usable fraction of the theoretical 4GB
depends on the environment; not all restrict the process to
half the address space.)

Whatever the machine, though, if Java's memory grows to
the point where significant swapping occurs it will not so
much "run" as "crawl" ...
 
J

Juan Singh

Eric said:
Juan Singh wrote On 02/02/07 15:54,:

That may be true of some systems, but surely not of all.
On the Solaris box I happen to be using at the moment I can
get to -Xmx3908m, about 90% of the full 4GB. Windows and
Linux and Mac and whatever may have different limits. (Yes,
Solaris is a 64-bit O/S. However, the JVM I used is a 32-bit
application, hence limited to no more than 4GB no matter what.
My point is that the usable fraction of the theoretical 4GB
depends on the environment; not all restrict the process to
half the address space.)

Whatever the machine, though, if Java's memory grows to
the point where significant swapping occurs it will not so
much "run" as "crawl" ...


The 2GB limit exists only on 32 bit NT and Linux. Even though
theoretical limit on Linux is 4GB, pthreads cannot handle more than 2.

A 64 bit machine and compatible VM can allocated a lot more than 4 GB.

If you try to allocate the Java heap close to the max, it does not leave
anything for the VM and therefore, you get that error.

Refer to http://java.sun.com/docs/hotspot/HotSpotFAQ.html#gc_heap_32bit
for a better explanation.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Juan said:
On a 32-bit machine a process cannot get more than 2GB regardless of how
much physical memory you have on the machine.

On 32 bit Windows you can not get more than 2 GB unless you use
the /3GB switch.
-Xmx defines the Java heap size, which does not include the size for the
VM itself. From the OS perspective any java program will take
JavaHeapSize + VM Size. Therefore, I suggest that you never exceed 1.5
GB for java heap.

Yep.

Various version of SUN Java, IBM Java and BEA Java has
different limits, but they are all in the 1.5-1.7 GB range.

And I believe even so with the /3GB switch.

Arne
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top