This discussion is archived
4 Replies Latest reply: Apr 6, 2012 12:28 AM by tdy218 RSS

High Java memory consumption.

926559 Newbie
Currently Being Moderated
Hello,

Java processes RAM usage is increasing steadily, resulting in slow response.
Heap is configured to 2GB while starting the process but RSS=5.5GB and this keeps increasing till it uses up the entire RAM available.
(-Xss1m -XX:PermSize=128m -XX:MaxPermSize=256m -XX:NewRatio=2 -Xms2048m -Xmx2048m -XX:MaxPermSize=256m).
We are checking heap size using 'jvisualvm' and it is below 2GB.

Our application uses Java, Servlets and some web service calls.

-----

Environment:
OS: Red Hat Linux
App Server: jboss-5.1.0.GA
JVM: We have checked with 1.6.0_21, 1.6.0_26, 1.6.0_30

-----

Also the thread count is almost constant for over 24hrs but RSS value is increasing.
Date | Time | TotalThreads | DaemonThreads | NonDaemonThreads | VSZ | RSS | SZ | mapped: writeable/private: shared:
2012/3/13 | 11:50:48 | 277 | 245 | 32 | 3644988 | 3026036 | 911247 | mapped: 3653180K writeable/private: 3403160K shared: 3272K
2012/3/13 | 14:32:03 | 276 | 244 | 32 | 3817224 | 3186660 | 954306 | mapped: 3825416K writeable/private: 3545084K shared: 3272K
2012/3/13 | 18:00:03 | 276 | 244 | 32 | 4175848 | 3614728 | 1043962 | mapped: 4184040K writeable/private: 3950492K shared: 3272K
2012/3/14 | 00:00:03 | 276 | 244 | 32 | 4696012 | 4165484 | 1174003 | mapped: 4704204K writeable/private: 4480168K shared: 3272K
2012/3/14 | 06:00:03 | 276 | 244 | 32 | 5168076 | 4573556 | 1292019 | mapped: 5176268K writeable/private: 4884224K shared: 3272K
2012/3/14 | 12:00:04 | 276 | 244 | 32 | 5953416 | 5349432 | 1488354 | mapped: 5961608K writeable/private: 5643848K shared: 3272K
2012/3/14 | 15:00:03 | 276 | 244 | 32 | 6349600 | 5778032 | 1587400 | mapped: 6357792K writeable/private: 6077580K shared: 3272K

-----

Have I missed accounting for any factor that impacts java processes memory usage?
  • 1. Re: High Java memory consumption.
    EJP Guru
    Currently Being Moderated
    Have I missed accounting for any factor that impacts java processes memory usage?
    Yes, you've missed accounting for the piece of your code that causes this leak. Post some code.
  • 2. Re: High Java memory consumption.
    926559 Newbie
    Currently Being Moderated
    If there is a leak in our application code, JVM should run out of heap space & throw an out of memory error.
    In our case the heap size is within the set max value of 2GB but the java process memory usage is going upto 12GB.
  • 3. Re: High Java memory consumption.
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    Googling with the following seemed to suggest possibilities.

    java RSS memory

    In that I found the following interesting

    http://stackoverflow.com/questions/1612939/why-does-the-sun-jvm-continue-to-consume-ever-more-rss-memory-even-when-the-heap
  • 4. Re: High Java memory consumption.
    tdy218 Newbie
    Currently Being Moderated
    do you know java heap and native heap ? the -Xms and -Xmx are setting only for java heap.

    If you doubt there may be a native heap memory leak of jvm itself, you can use a toolkit named valgrind to find it.

    By the way , you should also check if there is jni invoking in jboss itself and you application , the jvm is writted by c++ and a little c, when you are using jdk api, it will cost memory in jvm process memory address space and java heap, and some java code will allocate memory outside the jvm heap area, such as java.nio.ByteBuffer.allocateDirect.

    You should also add -XX:+UseCompressedOops option to your jboss startup command line when you are using sun hotspot jvm 6u14 - 6u23, after 6u23, the option is open default.

    At last, there is a article in oracle support, the main points are following, hope to be helpful to you.

    Reasons for reaching this limit include:
    •     Memory leaks in calls to native libraries
    •     Loading many native libraries that fill up process address space
    •     Suboptimal JVM configurations due to changed memory requirements for an application
    •     Direct Buffers that are allocated outside of the garbage-collected heap
    (by java.nio.ByteBuffer.allocateDirect)
    •     Mapped Buffers, created by mapping a region of a file into memory
    (using java.nio.channels.FileChannel.map)
    •     mmap files using native implementations
    •     Any native resources that will tie up the address space