56

I'm looking for a tool or a script that will take the console log from my web app, parse out the garbage collection information and display it in a meaningful way.

I'm starting up on a Sun Java 1.4.2 JVM with the following flags:

-verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails

The log output looks like this:

54.736: [Full GC 54.737: [Tenured: 172798K->18092K(174784K), 2.3792658 secs] 257598K->18092K(259584K), [Perm : 20476K->20476K(20480K)], 2.4715398 secs]

Making sense of a few hundred of these kinds of log entries would be much easier if I had a tool that would visually graph garbage collection trends.

starblue
  • 55,348
  • 14
  • 97
  • 151
braveterry
  • 3,724
  • 8
  • 47
  • 59
  • 2
    There's a commercial product JClarity Censum, which i haven't tried. However, this talk by its author was quite informative on Java GC in general: http://www.infoq.com/presentations/Visualizing-Java-GC – Dan Pritts Jul 22 '13 at 19:42

12 Answers12

33

gcviewer does what you want.

kohlerm
  • 2,596
  • 1
  • 17
  • 22
  • 2
    gcviewver was released in 2008. Can it parse Sun JVM 1.6 logs correctly? For me it generates a lot of `NumberFormatException`s but shows some information. Question is: can I trust it? – dma_k Sep 26 '11 at 08:54
  • So far I think you can trust it. – kohlerm Sep 29 '11 at 08:27
  • 12
    I really recommend to get the latest version from https://github.com/chewiebug/GCViewer – Yves Martin Feb 08 '12 at 11:08
17

IBM's GC toolkit does exactly what you ask.

https://www.ibm.com/developerworks/java/jdk/tools/gcmv/

I'm not sure if it's compatible with GC logs from Sun's JVM though.

Jesudas
  • 83
  • 1
  • 8
bajafresh4life
  • 12,491
  • 5
  • 37
  • 46
  • This one is not perfect, but it does what I need it to do. It seems to be geared towards the IBM JDK, but it mostly works with the java GC log format. There are a couple of bits of information that don't get parsed out, but most of the data is there. Thanks! – braveterry Feb 13 '09 at 15:17
  • IBM now delivers a suite of tools bundled in a really large package "IBM Support Assistant" http://www-01.ibm.com/support/docview.wss?uid=swg27023689 For GC log analysis, you have to use the "Garbage Collection and Memory Visualizer (GCMV)" – Yves Martin Feb 08 '12 at 11:11
  • IBM provides also "IBM Pattern Modeling and Analysis Tool for Java Garbage Collector (PMAT)" (last updated november 2012) https://www.ibm.com/developerworks/community/groups/service/html/communityview?communityUuid=22d56091-3a7b-4497-b36e-634b51838e11 – Julien Kronegg Dec 06 '12 at 11:35
12

I think some people are adding Java probes which don't really parse garbage collection logs as the question states...

I've tried others (gcviewer, gchisto, IBM's) and the best tool I found for analyzing GC logs is HPjmeter

It is mainly for HP-UX JVMs, but it also usually works with Sun JVMs and does a great job.

alt text
(source: xebia.com)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
fglez
  • 8,422
  • 4
  • 47
  • 78
  • I am playing with HPjmeter 4.1.00.00 and I can't open Sun JDK log files with it. They have the format mentioned by **braveterry** in his question. – dma_k Sep 26 '11 at 08:48
  • It 'usually' works for Sun JVMs but I've had problems reading some CMS GC messages which I had to filter to load the file. Which JDK version are logs from? Which GC args are used to start the JVM? – fglez Sep 26 '11 at 17:02
  • Sun JDK 1.6u27, `-verbose:gc -XX:+PrintGCDetails`. But the problem is more trivial: `*.log` files are not listed in program available filters, so HPjmeter can't open it. When I rename it, HPjmeter fails. How do you name the files, produced by GC? – dma_k Sep 26 '11 at 23:04
  • 1) Change file type combo box to show all files 2) Use -Xloggc: instead of -verbose:gc – fglez Sep 27 '11 at 07:07
  • Just rename the Sun JDK verbose GC logs to .hprof from .log and you will be able to load them in HPJMeter. It's a brilliant tool. GCViewer barfed on some of the Sun JDK 1.6 logs but not this. – Ashwin Jayaprakash Oct 21 '11 at 16:00
  • 1
    I get "No useful data in file" error, even after renaming the file .hprof. The problem is of course not the filename, as I can make it open the .log file also, by just entering the name. – haridsv May 19 '14 at 20:54
  • I used in the past, HP Jmeter doesn't support SUN JDK GC log nowadays. – Mohan Narayanaswamy Oct 15 '14 at 09:49
10

I tried a online tool http://gceasy.io , it can read my sun jdk 1.8 gc log.

craig_wu9
  • 201
  • 4
  • 8
7

The most powerful tool I've found to work with both IBM and Hotspot JVM logs and visualize them is IBM's PMAT: https://www.ibm.com/developerworks/mydeveloperworks/groups/service/html/communityview?communityUuid=22d56091-3a7b-4497-b36e-634b51838e11

I find it both faster and gives more details than the tool in IBM Support Assistant. It is being continually updated, lastly July'12.

However seems to have some problems parsing logs with policy CMS but hopefully that can be fixed.

PrintGCStats is pretty good too, and gives good statistics, but not for visualization over time, that needs some work.

Stian Lund
  • 193
  • 2
  • 12
7

Even better than jconsole is visualvm, which is developed and distributed freely by Sun. It has a GC analyzing plugin called gchisto which might help you.

Edit: Sorry, I didn't see your JDK 1.4.2 requirement. In that case visualvm won't help you, alas.

fred-o
  • 1,342
  • 8
  • 12
5

I use YourKit java profiler, which lets you measure this sort of thing, and much more, but using it's own format rather than analysing the log. It can do more under Java 5, but should work under 1.4.

Nick Fortescue
  • 43,045
  • 26
  • 106
  • 134
3

Try VisualGC from Sun. There are JDK 4 and 5 versions that give you a nice visual of what's going on in the eden, generational, and perm spaces. You need to add a JAR and get a PID and Bob's your uncle.

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • 2
    VisualGC is also available as a graphical plugin in VisualVM but it only works "live" and as far as I know it is not able to process a GC log file. – Yves Martin Feb 08 '12 at 11:09
  • Yes, I'd recommend Visual VM now, too. I wrote this three years ago; the world has changed. I don't revisit every answer and keep them up to date. – duffymo Feb 08 '12 at 13:01
  • 3
    I agree. I just want to point that the question is about analyzing GC log file "offline" whereas VisualGC is a "live" tool. – Yves Martin Feb 09 '12 at 07:36
3

A few years ago, John Coomes (Hotspot GC group) had released PrintGCStats, an awk script to "summarize statistics about garbage collection, in particular gc pause time totals, averages, maximum and standard deviations.". A copy of the script is hosted on java.net : http://java.net/projects/printgcstats

2

gchisto plugin for VisualVM doesn't work https://gchisto.dev.java.net/

I have a file with all details of printgc for jdk1.6 but couldn't find a tool to read that. Previously with jdk1.5 we used HPjmeter it worked fine, but now with jdk1.6 it doesn't

Tried following: IBM Pattern Modeling and Analysis Tool for Java Garbage Collector -- it doesn't recognizes the file. GCCollector doesn't work, it keep on reading file for analysis.

Aleš
  • 8,896
  • 8
  • 62
  • 107
user504279
  • 21
  • 2
2

jconsole can help you a lot, but I think it's Java 5 and later only. Once I heard someone of SUN speaking at our university and he said that Java 6's garbage collector is A LOT better than the old ones which needed complicated tuning nearly all the time for big applications. Java 6 GC seems to scale a lot better on SMPs.

Johannes Weiss
  • 52,533
  • 16
  • 102
  • 136
  • 1
    Does `jconsole` support analysis of offline log files? I see there is only _Connect_ menu. – dma_k Sep 26 '11 at 09:07
1

How about trying out some profiling tool like JProbe Freeware (Eclipse plug-in).

Petteri H
  • 11,779
  • 12
  • 64
  • 94
  • 1
    You cannot profile your production environment. Load a test environment with relevant scenarios is the first step for gc/memory tuning but then you have to validate that the tuning has the expected effect in production thanks to GC log analysis – Yves Martin Feb 08 '12 at 11:18