RESTful API to analyze garbage collection logs

RESTful API to analyze garbage collection logs

  • 2016-09-05
  • 428

Garbage collection log is a vital artifact to study performance characteristics of an application. It plays a vital role in diagnosing memory or CPU related problems.

However, today’s world Garbage collection logs are analyzed manually. Most often it’s analyzed only when there is a performance problem. There is no programmatic way to analyze Garbage Collection logs in a proactive manner. Thus is introducing a RESTful API to analyze garbage collection logs. Here are a couple of use cases where this API can be used.

Use case 1: Production Proactive GC Log analysis

In the production environment, where several JVMs are running, only selective few JVM’s Garbage Collection logs are analyzed. Because of the tediousness involved in analyzing all the Garbage Collection logs, not every single JVMs Garbage Collections are analyzed. Most of the times, only when there is a performance problem, Garbage Collection logs are analyzed. 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, besides that 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 after all tests are executed against the source code, Garbage Collection log analysis API can be invoked to see whether the application is suffering from any memory problems. If API reports any memory problems, then build can be failed. In this way, you can catch the memory problem right during code commit time instead of catching it in performance tests or production.

How to invoke Garbage Collection log analysis API?

Invoking Garbage Collection log analysis is an extremely 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 problems have been discovered. “problem” element will contain the detailed description of the memory problem. A sample response is given below.

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<API-KEY> --header "Content-Type:text"**

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

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

JSON Response Elements
JSON Response Elements
JSON Response Elements
JSON Response Elements


The Complete Web Developer Course - Build 14 Websites

ASP NET Core (ASP NET 5),MVC 6,C#,Angular2 & EF Crash Course


Ultimate Facebook CHATBOT Course: Talk to a Billion users!

Managed Extensibility Framework, MEF, from Novice to Guru