6 Replies Latest reply: Jun 13, 2011 11:34 PM by 868448 RSS

    Resident memory of java application

    868448
      Hi,

      When I start my application, I have set max heap size as 2 GB (-Xmx2048M). Since I set max heap size as 2 GB, the resident memory of the java application should be less than 2.5 GB ( Max Heap + Jars Memory + VM Memory ). But the resident memory of the java application is keep increasing (4+ GB) without throwing OutOfMemory error. When I see the java heap memory usage using JMX, it shows only 1.6 GB. The gc.txt log also shows only 1.6 GB.

      I assume, there is no memory leak in my java code because of below reasons,

      There is no OutOfMemroy error, even though java resident memory shows 4+ GB.
      The JMX stats shows memory heap size as 1.6 GB.

      I don't why the resident memory of the java application keep increasing without OutOfMemory. As per my knowledge, there are 2 cases this will happen,

      If the java app triggers any process using Runtime.getRuntime() and the process has memory leak
      If the java app triggers any native call (JNI) and the native implementation has memory leak

      In my case, my java app neither use any Runtime.getRuntime() method call nor my own native implementation call. But the resident memory of my java app is keep increasing without OutOfMemory error.

      My Setup Details :

      JDK : java version "1.6.0_16" - Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
      OS  : Linux x.x.x.x 2.6.18-194.11.4.el5 #1 SMP Tue Sep 21 05:04:09 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
      Java GC Options : -Xmx2048M -Xms2048M -XX:+UseConcMarkSweepGC -XX:+HeapDumpOnOutOfMemoryError -verbose:gc -Xloggc:../logs/gc.txt -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime

      Can you please help me to solve this issue ? Kindly let me know, if you require any other information.

      Thanks,
      Ramesh
        • 1. Re: Resident memory of java application
          EJP
          Since I set max heap size as 2 GB, the resident memory of the java application should be less than 2.5 GB ( Max Heap + Jars Memory + VM Memory ).
          Only if you assume the latter two items take up <= 0.5GB each. Do they?
          • 2. Re: Resident memory of java application
            868448
            EJP wrote:
            Since I set max heap size as 2 GB, the resident memory of the java application should be less than 2.5 GB ( Max Heap + Jars Memory + VM Memory ).
            Only if you assume the latter two items take up <= 0.5GB each. Do they?
            I am not 100% sure. Just gave worst case assumption. If my code base/jar is high, I should get java.lang.OutOfMemoryError: PermGen space. right ? Do you have any idea ?
            • 3. Re: Resident memory of java application
              802316
              What is your maximum direct memory? By default its the same as the heap memory maximum. This can give you a maximum size of 2 GB (heap) + 2 GB (direct) + 0.5 - 1.0 GB for the rest.

              BTW: I would try updating your JVM, it is 10 updates behind current.

              If you do that, something which can reduce memory consumption without too much overhead is -XX:+UseCompressedOops and -XX:+UseCompressedStrings
              • 4. Re: Resident memory of java application
                EJP
                I am not 100% sure. Just gave worst case assumption.
                No you didn't. It isn't a 'worst case assumption'. It's just a guess. The true figure might be higher. That's my point. In this case obviously something is a lot higher. The current case is worse than your 'worst case'.
                If my code base/jar is high, I should get java.lang.OutOfMemoryError: PermGen space. right?
                Among other possibilities. But there is also the question of how much memory the JVM itself needs.
                • 5. Re: Resident memory of java application
                  jschellSomeoneStoleMyAlias
                  JRK wrote:
                  ....without throwing OutOfMemory error.
                  ...
                  Can you please help me to solve this issue ? Kindly let me know, if you require any other information.
                  What is the "issue" exactly?

                  Since there is no OOM that certainly isn't the issue.
                  So explain in detail why you think what you are seeing is a problem - specifically what impact it is going to have.
                  • 6. Re: Resident memory of java application
                    868448
                    Thanks to all for your help.
                    No you didn't. It isn't a 'worst case assumption'. It's just a guess.
                    Yes. It is just a guess not worst case assumption.
                    jschell wrote:
                    JRK wrote:
                    ....without throwing OutOfMemory error.
                    ...
                    Can you please help me to solve this issue ? Kindly let me know, if you require any other information.
                    What is the "issue" exactly?

                    Since there is no OOM that certainly isn't the issue.
                    So explain in detail why you think what you are seeing is a problem - specifically what impact it is going to have.
                    My server m/c has 8 GB RAM and I am running 2 instance of my java application in that m/c. Since each instance of memory goes to 4 GB, the m/c is not reachable. Because no more memory is available for open ssh session.
                    What is your maximum direct memory? By default its the same as the heap memory maximum. This can give you a maximum size of 2 GB (heap) >+ 2 GB (direct) + 0.5 - 1.0 GB for the rest.
                    I didn't mention anything. So it should be default ( 2GB). Thanks Peter Lawrey. Now, I understand that, the memory wiIl go upto 5GB in my case.

                    Thanks,
                    Ramesh