dschneider-pivotal commented on a change in pull request #7407:
URL: https://github.com/apache/geode/pull/7407#discussion_r837867466



##########
File path: 
geode-core/src/main/java/org/apache/geode/internal/offheap/FreeListManager.java
##########
@@ -518,10 +520,51 @@ boolean doDefragment(int chunkSize) {
     ma.getStats().setLargestFragment(largestFragment);
     ma.getStats().setFragments(tmp.size());
     ma.getStats().setFragmentation(getFragmentation());
+    ma.getStats().setFreedChunks(0);
 
     return result;
   }
 
+  public void updateNonRealTimeStats() {
+    ma.getStats().setLargestFragment(getLargestFragment());
+    ma.getStats().setFreedChunks(getFreedChunks());
+  }
+
+  public int getFreedChunks() {
+    int elementCountFromTinyFreeLists =
+        getElementCountFromTinyFreeLists();
+    int elementCountFromHugeFreeLists =
+        getElementCountFromHugeFreeLists();
+
+    return elementCountFromTinyFreeLists + elementCountFromHugeFreeLists;
+  }
+
+  private int getElementCountFromTinyFreeLists() {
+    int fragmentCount = 0;
+    for (int i = 0; i < tinyFreeLists.length(); i++) {
+      OffHeapStoredObjectAddressStack cl = tinyFreeLists.get(i);
+      if (cl != null) {
+        fragmentCount += cl.size();
+      }
+    }
+    return fragmentCount;
+  }
+
+  private int getElementCountFromHugeFreeLists() {
+    return hugeChunkSet.size();
+  }
+
+  private int getLargestFragment() {
+    int largestFreeSpaceFromFragments = 0;

Review comment:
       would "largestFragmentSize" be a better name? It should probably match 
the method name without the "get" prefix.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@geode.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to