Skip to content

Commit

Permalink
handle null pointer exception in swap memory read
Browse files Browse the repository at this point in the history
  • Loading branch information
burak-58 committed Mar 22, 2021
1 parent b48e61f commit f2a458f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/java/io/antmedia/statistic/StatsCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,15 @@ public static JsonObject getSysteMemoryInfoJSObject() {
jsonObject.addProperty(TOTAL_MEMORY, SystemUtils.osTotalPhysicalMemory());
jsonObject.addProperty(FREE_MEMORY, SystemUtils.osFreePhysicalMemory());
jsonObject.addProperty(IN_USE_MEMORY, SystemUtils.osInUsePhysicalMemory());
jsonObject.addProperty(TOTAL_SWAP_SPACE, SystemUtils.osTotalSwapSpace());
jsonObject.addProperty(FREE_SWAP_SPACE, SystemUtils.osFreeSwapSpace());
jsonObject.addProperty(IN_USE_SWAP_SPACE, SystemUtils.osInUseSwapSpace());

//to handle the problem in raspberry pi4 + ubuntu 20.04
try {
jsonObject.addProperty(TOTAL_SWAP_SPACE, SystemUtils.osTotalSwapSpace());
jsonObject.addProperty(FREE_SWAP_SPACE, SystemUtils.osFreeSwapSpace());
jsonObject.addProperty(IN_USE_SWAP_SPACE, SystemUtils.osInUseSwapSpace());
}catch (Exception e) {
logger.error("swap memory statistic can not be read");
}

jsonObject.addProperty(AVAILABLE_MEMORY, SystemUtils.osAvailableMemory());

Expand Down

0 comments on commit f2a458f

Please sign in to comment.