This discussion is archived
8 Replies Latest reply: Jan 27, 2013 11:03 AM by jschellSomeoneStoleMyAlias RSS

what 2 % of heap size should be free

987092 Newbie
Currently Being Moderated
Hi users..
Greetings

We recently moved to jdk 1.6.0(minor version 22) , we faced the exception

Stack Trace of Throwable: java.lang.OutOfMemoryError: GC overhead limit exceeded.

Server running the application : solaris

It was working without any issues in 1.4.
We found few information from site http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html

It says

"if more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered, an OutOfMemoryError will be thrown. This feature is designed to prevent applications from running for an extended period of time while making little or no progress because the heap is too small. If necessary, this feature can be disabled by adding the option -XX:-UseGCOverheadLimit to the command line.

My question over here is what 2% of heap to recover , whether this 2% is with reference to the default minimum heap size of JVM or the one set in the JVM parameters in the application.

The JVM parameter set for our application is

JAVA_HOME/bin/java -server -Dname=NMSAPP-$1 -Xms2G -Xmx2G -XX:-UseCompilerSafepoints com.nms.NetStartUp

Here my heap size which I had set in my application is 2 GB .Is that 2 % is for that 2 GB size?

Thanks in advance..
  • 1. Re: what 2 % of heap size should be free
    EJP Guru
    Currently Being Moderated
    My question over here is what 2% of heap to recover , whether this 2% is with reference to the default minimum heap size of JVM or the one set in the JVM parameters in the application.
    2% of the heap. The actual heap. Hard to see why you would think anything else.
  • 2. Re: what 2 % of heap size should be free
    987092 Newbie
    Currently Being Moderated
    Thanks,
    But I could not get from you what is the "actual heap size".

    we have two parameters Minimum heap size (-Xms2G) and maximum heap size(-Xmx2G).I just wanted to know that 2% is for the minimum heap size or the maximum heap size that was configured as JVM parameters.Can you please make it clear if my understanding is not correct..
  • 3. Re: what 2 % of heap size should be free
    gimbal2 Guru
    Currently Being Moderated
    984089 wrote:
    we have two parameters Minimum heap size (-Xms2G) and maximum heap size(-Xmx2G).I just wanted to know that 2% is for the minimum heap size or the maximum heap size that was configured as JVM parameters.Can you please make it clear if my understanding is not correct..
    Those are boundaries only, configuration.
    But I could not get from you what is the "actual heap size".
    The heap as it exists when the JVM is actually running, which is minimally what you provided with Xms and maximally what you provided with Xmx. So lets say you set the minimum at 100mb and the maximum at 200mb, the heap size will start at 100mb in size. When you create 150mb worth of objects, the heap will be 150mb (give or take). If you claim 50mb worth of objects more, the heap will be 200mb. If you try to use more memory, you'll get an out of memory error because the heap is not allowed to grow beyond 200mb.

    So yeah - there is only one heap to speak of (per JVM instance).
  • 4. Re: what 2 % of heap size should be free
    987092 Newbie
    Currently Being Moderated
    Thanks,

    In JRE 1.4 we kept the minimum heap size as 256M . But in 1.6 we increased it to 2G (now both min and max heap size are 2G only).will this change in size could anyway
    cause this exception to occur.

    Stack Trace of Throwable: java.lang.OutOfMemoryError: GC overhead limit exceeded.

    Can you please advice on this front.

    Thanks in advance
  • 5. Re: what 2 % of heap size should be free
    gimbal2 Guru
    Currently Being Moderated
    984089 wrote:
    Can you please advice on this front.
    Nope. But what you can do is paste that exact error message into google, you are not the first one that ran into this.
  • 6. Re: what 2 % of heap size should be free
    987092 Newbie
    Currently Being Moderated
    Thanks,

    My concern over here is our application is running in jre 1.4 for years, we haven't faced this OutOfmemoryError .Its only a couple of days since we moved to 1.6 ,we started facing this issue.We didn't make any big change in the application that may consume more memory or considerable change in the load .We just upgraded to jre 1.6.
    Is there anything specific to jre 1.6 that we missed to configure here which might caused this error ?.I am giving my JVM parameters once again..

    JAVA_HOME/bin/java -server -Dname=NMSAPP-$1 -Xms2G -Xmx2G -XX:-UseCompilerSafepoints com.nms.NetStartUp

    can anyone advice on the same.

    Thanks in advance
  • 7. Re: what 2 % of heap size should be free
    gimbal2 Guru
    Currently Being Moderated
    984089 wrote:
    Is there anything specific to jre 1.6 that we missed to configure here which might caused this error ?.I am giving my JVM parameters once again..
    I have been using Java since 1.2 and I've upgraded to every version available. Besides setting proper heap space and debug settings I have -never- had to specifically configure anything.

    I tend to keep minimum and maximum heap settings far apart; minimal 128mb and maximum as much as you think you need. I let the JVM figure out how much it really needs during runtime, I'm not going to force anything on it. I have no idea if that is going to change anything for you, all I can say is that it works just fine for me. Your out of memory problems are probably still the result of a bug in you application, no matter how much you want to believe it is the runtime or its configuration.
  • 8. Re: what 2 % of heap size should be free
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    SD13 wrote:
    Thanks,

    My concern over here is our application is running in jre 1.4 for years, we haven't faced this OutOfmemoryError .Its only a couple of days since we moved to 1.6 ,we started facing this issue
    Did you update ANYTHING else? Like third party libraries, like JEE containers, like JDBC drivers, like OS/Platform?

    If and only if the answer is no then note that the way the GC works in 1.6 changed quite a bit since 1.4. There are options to change how it behaves.

    Might note as well that upgrading to 1.6 rather than 1.7 at this time is probably not a good idea.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points