Based on the JVM version (1.4, 5, 6, 7, 8, 9), JVM vendor (Oracle, IBM, HP, Azul, Android), GC algorithm (Serial, Parallel, CMS, G1, Shenandoah) and few other settings, GC log format changes. Thus, today the world has ended up with several GC log formats.

‘GC Log standardization API’ normalizes GC Logs and provides a standardized JSON format as shown below.

Graphs provided by GCeasy is great, but some engineers would like to study every event of the GC log in detail. This standardized JSON format gives them that flexibility. Besides, that engineers can import this data to Excel or Tableau or any other visualization tool.

How to invoke Garbage Collection log standardization 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. Note: If you have purchased enterprise version, you don’t have to register. API key will be provided to you as a part of installation instruction.
  2. Post HTTP request to http://api.gceasy.io/std-format-api?apiKey={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 have 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 http://api.gceasy.io/std-format-api?apiKey= --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 web service client tools such as SOAP UI, Postman Browser Plugin,…..

postman
Fig: POSTing GC logs through PostMan plugin

Sample Response

{
    "gcEvents": [
        {
            "timeStamp": "15:49:55",
            "gcType": "YOUNG",
            "durationInSecs": 0.077381,
            "pauseDurationInSecs": 0.077381, 
            "reclaimedBytes": "387.64258 mb",
            "heapSizeBeforeGC": "1031.0488 mb",
            "heapSizeAfterGC": "643.40625 mb",
            "youngGenSizeBeforeGC": "1024.0 mb",
            "youngGenSizeAfterGC": "636.3584 mb",
            "oldGenSizeBeforeGC": "7.048828 mb",
            "oldGenSizeAfterGC": "7.048828 mb"
        },
        {
            "timeStamp": "15:51:15",
            "gcType": "FULL",
            "durationInSecs": 0.344394,
            "pauseDurationInSecs": 0.344394, 
            "reclaimedBytes": "6.053711 mb",
            "heapSizeBeforeGC": "1663.5732 mb",
            "heapSizeAfterGC": "1657.5195 mb",
            "youngGenSizeBeforeGC": "671.3916 mb",
            "youngGenSizeAfterGC": "668.2207 mb",
            "oldGenSizeBeforeGC": "992.18164 mb",
            "oldGenSizeAfterGC": "989.2988 mb"
        },
        {
            "timeStamp": "15:53:19",
            "gcType": "YOUNG",
            "durationInSecs": 0.021699,
            "pauseDurationInSecs": 0.021699, 
            "reclaimedBytes": "737.67676 mb",
            "heapSizeBeforeGC": "2220.624 mb",
            "heapSizeAfterGC": "1482.9473 mb",
            "youngGenSizeBeforeGC": "1024.0 mb",
            "youngGenSizeAfterGC": "282.53516 mb",
            "oldGenSizeBeforeGC": "1196.624 mb",
            "oldGenSizeAfterGC": "1200.4131 mb"
        }
    ],
    "webReport": "http://gceasy.io/my-gc-report.jsp?p=YXJjaGl2ZWQvMjAxOS8xMS8yOS8tLWFwaS1lMDk0YTM0ZS1jM2ViLTRjOWEtODI1NC1mMGRkMTA3MjQ1Y2MyMzBkNzI2OS01NGU2LTRlMTktOTlmMC1kOWE2MjFhYmYwMmQudHh0LS0=&channel=API"
}

JSON Response Elements

ElementDescription
gcEventsThis is the top-level root element. It will contain an array of GC events. For every GC event reported in the GC Log, you will see an element in this array.
timeStampTimestamp at which particular GC event ran
gcTypeYOUNG – if it’s a young GC event type.
FULL – if it’s full GC event type.
durationInSecsDuration for which GC event ran
pauseDurationInSecsThere are multiple phases in one single GC event. Some phases pauses the application, some don’t. ‘pauseDurationInSecs’ shows the amount of time for which application was paused in a GC event. ‘durationInSecs’ shows the entire GC event’s duration. ‘pauseDurationInSecs’ will be subset of ‘durationInSecs’. Since GC analysis is primarily concerned only about pause duration, for all practical purposes you can use ‘pauseDurationInSecs’ instead of ‘durationInSecs’.
reclaimedBytesAmount of bytes reclaimed in this GC event
heapSizeBeforeGCOverall Heap size before this GC event ran
heapSizeAfterGCOverall Heap size after this GC event ran
youngGenSizeBeforeGCYoung Generation size before this GC event ran
youngGenSizeAfterGCYoung Generation size after this GC event ran
oldGenSizeBeforeGCOld Generation size before this GC event ran
oldGenSizeAfterGCOld Generation size after this GC event ran
permGenSizeBeforeGCPerm Generation size before this GC event ran
permGenSizeAfterGCPerm Generation size after this GC event ran
metaSpaceSizeBeforeGCMetaspace size before this GC event ran
metaSpaceSizeAfterGCMetaspace size after this GC event ran
webReportHyperlink which takes you to the web report for the GC log file.