In this modern world, Garbage collection logs are still analyzed in a tedious & manual mode. i.e. you have to get hold of your Devops engineer who has access to production servers, then he will mail you the application’s GC logs, then you will upload the logs to GC analysis tool, then you have to apply your intelligence to anlayze it. There is no programmatic way to analyze Garbage Collection logs in a proactive manner. Thus to eliminate this hassle, is introducing a RESTful API to analyze garbage collection logs. With one line of code you can get your GC logs analyzed instantly.

Here are a couple of use cases where this API can be extremely useful.

Use case 1: Production Proactive GC Log analysis

Depending on your traffic volume in production environment, your application might be deployed on tens or hundreds or thousands of JVMs. Because of the above mentioned tediousness only selective few JVM’s Garbage Collection logs are analyzed. You wouldn’t be able analyze all the hundreds of JVMs GC logs.

With Garbage Collection analysis API, you can analyze GC logs in a proactive manner. On a periodic basis, you can invoke Garbage Collection analysis API to check whether any problem is brewing in the application. Garbage Collection log analysis API reports any vulnerabilities that are currently happening in the application + its ML algorithms can even forecast certain types of memory problems that’s going to happen in near future.

Use case 2: Continuous Integration

As part of continuous integration it’s highly encouraged to execute performance tests. Garbage collection log from this execution can be analyzed using the API.  If API reports any problems, then build can be failed. In this way, you can catch the memory problems and other performance degradation right during code commit time instead of catching it in  performance labs or production.

How to invoke Garbage Collection log analysis API?

Invoking Garbage Collection log analysis is very simple:

  1. Register with us. We will email you the API key. This is a one-time setup process.
  2. Post HTTP request to{API_KEY_SENT_IN_EMAIL}
  3. The body of the HTTP request should contain the Garbage collection log that needs to be analyzed.
  4. HTTP Response will be sent back in JSON format. JSON has several important stats about the GC log. Primary element to look in the JSON response is: “isProblem“. This element will have value to be “true” if any memory/performance problems has been discovered. “problem” element will contain the detailed description of the memory problem.

CURL command

Assuming your GC log file is located in “./my-app-gc.log,” then CURL command to invoke the API is:

curl -X POST --data-binary @./my-app-gc.log --header "Content-Type:text"

It can’t get any more simpler than that? Isn’t it? 🙂

Note:  use the option “–data-binary” in the CURL instead of using “–data” option. In “–data” new line breaks will be not preserved in the request. New Line breaks should be preserved for legitimate parsing.

Other Tools

You can also invoke the API using any webservice client tools such as: SOAP UI, Postman Browser Plugin,…..


Fig: POSTing GC logs through PostMan plugin

Sample Response

  "responseId": "03d4eab6-2070-4081-a1dc-273e213c5175",
  "graphURL": "",
  "isProblem": true,
  "problem": [
    "Our analysis tells that your application is suffering from memory leak. It can cause OutOfMemoryError, JVM to freeze, poor response time and high CPU consumption."
  "jvmHeapSize": {
    "youngGen": {
      "allocatedSize": "1.3 gb",
      "peakSize": "1.3 gb"
    "oldGen": {
      "allocatedSize": "2.67 gb",
      "peakSize": "2.67 gb"
    "permGen": {
      "allocatedSize": "285 mb",
      "peakSize": "214.54 mb"
    "total": {
      "allocatedSize": "3.87 gb",
      "peakSize": "3.64 gb"
  "gcStatistics": {
    "totalCreatedBytes": "6.07 tb",
    "measurementDuration": "29 hrs 15 min 28 sec",
    "avgAllocationRate": "60.38 mb/sec",
    "avgPromotionRate": "284 kb/sec",
    "minorGCCount": "10566",
    "minorGCTotalTime": "3 min 40 sec 168 ms",
    "minorGCAvgTime": "21 ms",
    "minorGCAvgTimeStdDeviation": "6 ms",
    "minorGCMinTIme": "10 ms",
    "minorGCMaxTime": "90 ms",
    "minorGCIntervalAvgTime": "9 sec 755 ms",
    "fullGCCount": "1071",
    "fullGCTotalTime": "37 min 15 sec 829 ms",
    "fullGCAvgTime": "2 sec 88 ms",
    "fullGCAvgTimeStdDeviation": "793 ms",
    "fullGCMinTIme": "100 ms",
    "fullGCMaxTime": "4 sec 920 ms",
    "fullGCIntervalAvgTime": "1 min 38 sec 431 ms"
  "gcDurationSummary": {
    "groups": [
        "start": "0",
        "end": "1",
        "numberOfGCs": 10622
        "start": "1",
        "end": "2",
        "numberOfGCs": 316
        "start": "2",
        "end": "3",
        "numberOfGCs": 565
        "start": "3",
        "end": "4",
        "numberOfGCs": 128
        "start": "4",
        "end": "5",
        "numberOfGCs": 6

JSON Response Elements

Element Description
responseId Unique transaction Id that is generated for every response. This is used for any debugging or diagnosis purposes
graphURL Graphical visualization of the GC log can be found at this location.
isProblem true’ is returned if any memory problems are found. ‘false’ is returned if no memory problems are found. This element can be used to build any alerts for proactive GC monitoring
problem Description of the memory problem is reported in this element. Like what type of memory problem, it is. What are the side-effects and symptoms it might cause
jvmHeapSize The data points in this section is gathered from the GC log, thus It may or may not match with the size that is specified by the JVM system properties (i.e. –Xmx, -Xms,…). Say you have configured total heap size (i.e. –Xmx) as 2gb, whereas at runtime if JVM has allocated only 1gb, then in this report you are going to see the allocated size as 1gb only.
allocatedSize Young Generation’s allocated size (i.e. specified at the JVM level)
peakSize Young Generation’s peak utilization size at runtime
allocatedSize Old Generation’s allocated size (i.e. specified at the JVM level)
peakSize Old Generation’s peak utilization size at runtime
allocatedSize Metaspace’s allocated size (i.e. specified at the JVM level)
peakSize MetaSpace’s peak utilization size at runtime
allocatedSize Perm Generation’s allocated size (i.e. specified at the JVM level)
peakSize Perm Generation’s peak utilization size at runtime
allocatedSize Total allocated heap size (i.e. specified at the JVM level) includes Young + Old + Perm (or Metaspace)
peakSize Peak utilization of the heap size at runtime
gcStatistics GC statistics summary is based on ‘real’ time reported in the GC Logs. For more details on difference between user, sys, real time refer to
totalCreatedBytes Total amount of objects created by the application
measurementDuration Total time duration application has been running
avgAllocationRate Objects creation rate by the application. When more objects are allocated, young generation gets filled up quickly, and Minor GC runs more frequently.
avgPromotionRate Objects promoted rate from Young Generation to Old Generation. When more objects are promoted to Old generation, Full GC will be run more frequently.
minorGCCount Number of Minor GCs occurred in the application
minorGCTotalTime Total time spent in Minor GCs
minorGCAvgTime Average time taken by the Minor GCs (i.e. total time taken by all minor GCs / number of minor GCs)
minorGCAvgTimeStdDeviation Standard Deviation of the Minor GC average times
minorGCMinTIme Minimum Time of all the minor GCs
minorGCMaxTime Maximum time of all the minor GCs
minorGCIntervalAvgTime Average time interval between minor GCs
fullGCCount Number of Full GCs occurred in the application
fullGCTotalTime Total time spent in Full GCs
fullGCAvgTime Average time taken by the Full GCs (i.e. total time taken by all full GCs / number of full GCs)
fullGCAvgTimeStdDeviation Standard Deviation of the Full GC average times
fullGCMinTime Minimum Time of all the full GCs
fullGCMaxTime Maximum time of all the full GCs
fullGCIntervalAvgTime Average time interval between Full GCs
groups Array of GC Duration summary group. Example of a group:
“start”: “0.2”,
“end”: “0.3”,
“numberOfGCs”: 5
}, Indicates that 5 GCs completed between 0.2 second and 0.3 seconds
start Group’s start time reported in seconds
end Group’s end time reported in seconds
numberOfGCs Number of GCs that completed between ‘start’ time and ‘end’ time
gcCauses array  reporting the GC Causes
cause The reason which triggered the GC. Values could be: Concurrent Mode Failure, Allocation Failure, System.gc() calls
count Number of time GC occurred because of this reason
commandLineFlags JVM arguments that were passed to the application

Best Practice: Building alerts

For production monitoring or for performance tests, you can build alerts around the JSON response.

a. If “isProblem” element has value to be “true” then alert can generated with the content from “problem” element

b. You can also setup thresholds on the elements like: “fullGCCount”, “fullGCTotalTime”, “fullGCAvgTime”, “fullGCAvgTimeStdDeviation”, “fullGCMinTIme”, “fullGCMaxTime”,
“fullGCIntervalAvgTime”. If any these elements value exceeds your threshold then alerts can be triggered.