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
> 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
[quoted text clipped - 5 lines]
> 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.
cs5b@yahoo.com - 02 Feb 2007 21:00 GMT
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...
> c...@yahoo.com wrote:
> > I would like to instantiate the java jvm with a larger max heap size.
[quoted text clipped - 19 lines]
>
> Juan.
Eric Sosman - 02 Feb 2007 21:58 GMT
Juan Singh wrote On 02/02/07 15:54,:
>>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
[quoted text clipped - 8 lines]
> 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" ...

Signature
Eric.Sosman@sun.com
Juan Singh - 02 Feb 2007 22:30 GMT
> Juan Singh wrote On 02/02/07 15:54,:
>>
[quoted text clipped - 24 lines]
> 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.
Arne Vajhøj - 03 Feb 2007 02:45 GMT
> 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