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

Discussion in 'Java' started by cs5b@yahoo.com, Feb 2, 2007.

  1. Guest

    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
    , Feb 2, 2007
    #1
    1. Advertising

  2. Juan Singh Guest

    Re: How is the max value that you can set with the -Xmx param forheap size of the java jvm determined?

    wrote:
    > 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.
    Juan Singh, Feb 2, 2007
    #2
    1. Advertising

  3. Guest

    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...

    On Feb 3, 9:54 am, Juan Singh <> wrote:
    > wrote:
    > > 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.
    , Feb 2, 2007
    #3
  4. Eric Sosman Guest

    Re: How is the max value that you can set with the -Xmx param forheap size of the java jvm determined?

    Juan Singh wrote On 02/02/07 15:54,:
    > wrote:
    >
    >>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.


    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" ...

    --
    Eric Sosman, Feb 2, 2007
    #4
  5. Juan Singh Guest

    Re: How is the max value that you can set with the -Xmx param forheap size of the java jvm determined?

    Eric Sosman wrote:
    > Juan Singh wrote On 02/02/07 15:54,:
    >> wrote:
    >>
    >>> 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.

    >
    > 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.
    Juan Singh, Feb 2, 2007
    #5
  6. Re: How is the max value that you can set with the -Xmx param forheap size of the java jvm determined?

    Juan Singh wrote:
    > 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
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=, Feb 3, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben_
    Replies:
    1
    Views:
    4,908
  2. Replies:
    1
    Views:
    686
    Roedy Green
    Feb 14, 2006
  3. Michal Slocinski

    Heap dump file size vs heap size

    Michal Slocinski, Mar 25, 2008, in forum: Java
    Replies:
    1
    Views:
    723
    GArlington
    Mar 25, 2008
  4. Replies:
    8
    Views:
    16,257
    Arne Vajhøj
    May 12, 2009
  5. Raymond Schanks
    Replies:
    0
    Views:
    504
    Raymond Schanks
    Apr 11, 2010
Loading...

Share This Page