Issue #110: Fixed MaxSizeHeapPolicy and MaxSizeHeapPercentagePolicy. #134

wants to merge 1 commit into


None yet
2 participants

dvinas commented Apr 24, 2012

I made the following changes to

-Added a new method cost(), which determines the current cost of the map. (Tried to maintain a counter instead of iterating through the map, but records change size unpredictably, or have their values nulled before reindexing.)
-Fixed the implementations of both MaxSizeHeapPolicy and MaxSizeHeapPercentagePolicy using cost().
-Refactored startCleanup() so as not to call MapMaxSizePolicy.overCapacity() a 2nd time if it is called from CMap.overCapacity()->ConcurrentMapManager.executeCleanup() (indicated by forced=true). Removed redundant boolean logic.
-Added cost calculation to log message in startCleanup().


mdogan commented Apr 24, 2012

Thanks for the patch.

Problem here is that, CMap.overCapacity() is called before all put operations (PutOperationHandler) to check if map exceeds defined capacity but iterating through all records is too costly.

Instead we can set total cost calculated on every cleanup cycle to a volatile field in CMap and use that value during overcapacity check. I guess there is no need to be that much accurate.

@mdogan mdogan closed this Apr 27, 2012


mdogan commented Apr 27, 2012

See commit for #110

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment