Hi Darren,
Yes, HeapFriendlyMapArrayRecycler is intended to be used with multiple maps. We use it this way here at Netflix.
Just to double-check, are you following the instructions listed on
the wiki? Specifically, on each refresh you'll want to call:
HeapFriendlyMapArrayRecycler.get().swapCycleObjectArrays();
try {
/// make data available to application
} finally {
HeapFriendlyMapArrayRecycler.get().clearNextCycleObjectArrays();
}
Then, when making data available by creating new HeapFriendlyHashMaps, make sure you call releaseObjectArrays() on each of the old maps as you replace them with new ones.
You describe a scenario where you see heap usage rise to 90%, then drop to around 30%. The HeapFriendlyMapArrayRecycler won't ever release any memory. Assuming the above procedure is followed, once an Object array segment gets allocated to your HeapFriendlyHashMaps, it will shortly get promoted to tenured space, where it will live for the life of the application. These long-lived object array segments will be reused every other (alternating) refresh cycle.
Can you please confirm that even after major collections, the heap usage remains at 90%? If you grab a live histogram from an instance while it is stuck at 90% e.g. via:
jmap -histo:live <pid>
Do you see Object arrays as a top consumer?
Thanks,
Drew.