Performance and scalability: how to read free/total memory from GC's output ??

  1. Hi all,
    I'm in mess with GC JDK 1.4.x log output. I'd like to read -besides GC information-
    how much memory I have left and how much I'm using.

    This is a small dump from the GC log:

    976.578: [GC 976.578: [Tenured: 18115K->7153K(18116K), 0.3309426 secs] 19523K->7153K(19524K), 0.3459331 secs]
    980.544: [GC 980.544: [Tenured: 18115K->8080K(18116K), 0.1734528 secs] 19523K->8080K(19524K), 0.1949907 secs]
    982.783: [GC 982.783: [Tenured: 18115K->12388K(18116K), 0.1951404 secs] 19523K->12388K(19524K), 0.2119867 secs]
    986.579: [GC 986.579: [Tenured: 20647K->8289K(20648K), 0.1755991 secs] 22311K->8289K(22312K), 0.1924510 secs]

    From what I understand I have 8289K free memory and 22312K allocated.

    At the meantime my application dumps Runtime.freeMemory() and.Runtime().totalMemory();

    and numbers are quite different * about free memory *:

    Free memory: 3'787'672
    Total memory: 19'992'576

    Free memory: 1'800'240
    Total memory: 19'992'576

    Free memory: 4'216'928
    Total memory: 22'847'488

    Free memory: 4'024'792
    Total memory: 22'847'488

    Does anybody know how to read free/total memory from GC's output ??

    Threaded Messages (5)

  2. have a read of..[ Go to top ]


    this will help you understand the verbosegc output - main point is that there is no such thing as just "free memory", there many memory spaces (Sun refers to them as generations), so it depends which one you're talking about.
  3. A super-easy way to look at memory usage and gc in java is by using the jvmstat and visualgc tools. See
    GC in 1.4.2 - http://java.sun.com/docs/hotspot/gc1.4.2/index.html
    Visual GC tool - http://java.sun.com/performance/jvmstat/visualgc.html
    jvmstat - http://java.sun.com/performance/jvmstat/

    You will need to install JDK 1.5 to get the tools to work ... but then you use it to monitor your 1.4 instance.
  4. dfgdfgdfg[ Go to top ]

  5. JDK 5.0 JVM has much richer API, and good set of MBeans for capacity consumption monitoring. You can use MX4J or JConsole to interact with the MBeans.

    Check this out:

    Edmon Begoli
  6. Hi all,I'm in mess with GC JDK 1.4.x log output. I'd like to read -besides GC information-how much memory I have left and how much I'm using.

    You may try to ask to the garbage collector to provide you less information. If you merely add this parameter to the JVM...


    ... you are going to get this kind of information, that is much more easy to be read:

    [GC 46000 kb -> 24000 kb (0.010 sec]
    [GC 48000 kb -> 26000 kb (0.020 sec]
    [GC 49000 kb -> 23000 kb (0.015 sec]
    [Full GC 50000 kb -> 12000 kb (0.470 sec]

    This information is very easy to be understood. The first GC trace tells you that you had 46000 kb used, but that after 0.010 seconds of work, GC has freed 22000 kb. so you know have 24000 kb. used.

    The second trace and the third are the same, and the last trace is a full gargage collection. This last process tends to be more costly for the CPU, but on the other hand, you get more available memory.

    Hope this helps,
    Jose Ramon Huerga