Project

General

Profile

Bug #2198

#1

Updated by Venmuhilan B over 2 years ago

  • Status changed from New to In Progress
#2

Updated by Venmuhilan B over 2 years ago

The followings are the things I did to find the reason for java.lang.OutOfMemoryError: Java heap space

Tested the top traffic by adding system.gc() at the end of the loop(loop for collecting and processing 100 by 100 logs every time until the size of the logs) - the memory usage is not increasing continuously

Tested the top traffic by not adding system.gc() at the end of the loop(loop for collecting and processing 100 by 100 logs every time until the size of the logs) - the memory usage is increasing continuously

converted the static methods to normal methods(without adding system.gc() at the end of the loop)
private static String getLogEntries(String accessToken, String nextPageToken, String projectId , String startTime , String endTime, SERVICE serviceType)
private static JsonObject getTheRequestBody(String projectId, String startTime, String endTime, String nextPageToken, SERVICE serviceType)
private static String getTracesEntries(String accessToken, String nextPageToken, String projectId , String startTime , String endTime)
- the memory usage was still increasing continuously.

Added the code parts inside the loop in a separate method
- the memory usage was still increasing continuously.

Non-static Inner Class may cause memory leaks. TopTrafficMaps is an inner class present in the ExcelGeneration.java, I checked whether it is defined as static or not. TopTrafficMaps is a static inner class.

To do:

Do the profiling technique to detect the memory leak. There are some profiling tools like JProfiler which can be integrated into the eclipse.
TopTrafficMaps class is the class that has three maps where we are storing the details of the logs in the maps for every 100 by 100 logs. Instead of using TopTrafficMaps, we can write the logs directly into the respective sheets of the workbook and see whether the memory usage is constantly increasing for this.
#3

Updated by Venmuhilan B over 2 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100
#4

Updated by Ayush Khandelwal over 2 years ago

  • Due date changed from 03/18/2022 to 05/20/2022
  • Status changed from Resolved to Reopened
#5

Updated by Venmuhilan B over 2 years ago

Used Gson Streaming:
You can use JSON Object/ JSON Array only if the size of your json data is less than 1MB. Else you should go with JSONReader. JSONReader actually use streaming approach while JSONObject and JSONArray eventually load all the data on RAM at once which causes OutOfMemoryException in case of bigger json.
(reference:
https://sites.google.com/site/gson/streaming
https://stackoverflow.com/questions/14742902/parse-json-data-using-jsonreader-or-jsonobject-jsonarray
)

#6

Updated by Venmuhilan B over 2 years ago

  • Status changed from Reopened to In Progress
#7

Updated by Ayush Khandelwal over 2 years ago

  • Status changed from In Progress to Closed
  • Assignee changed from Venmuhilan B to Ayush Khandelwal

Untraceable. so, closing it for now

Also available in: Atom PDF