Some caches (internally implemented as UnifiedMap) can grow quite large over time. Majority of data in them is likely to still continue to be used, but definitely not all. This causes gradual buildup of data in caches which can in extreme cases lead to OutOfMemory error.
For example:
GenericStatsCollectorsFactory.EXISTING_COLLECTORS_MAP - this one is the biggest problem
JsonUtil.CACHED_PARSED_NODES - also very big
JsonUtil.EXTRACTED_EXPRESSIONS - much smaller than other two, but still using noticeable amount of memory (in one heap dump it was around 10MB)
There are other caches that should probably also be handled, but they are far from critical.
The question is how to do this - UnifiedMap is nice because it saves a lot of memory compared to other map implementations. So ideally we'd keep it and clean data from it. One simple brute-force solution could be to just recreate cache maps once a day. This would cause a spike in CPU usage for few seconds (or a bit more), until fresh entries get populated into newly created maps.
Some caches (internally implemented as UnifiedMap) can grow quite large over time. Majority of data in them is likely to still continue to be used, but definitely not all. This causes gradual buildup of data in caches which can in extreme cases lead to OutOfMemory error.
For example:
GenericStatsCollectorsFactory.EXISTING_COLLECTORS_MAP
- this one is the biggest problemJsonUtil.CACHED_PARSED_NODES
- also very bigJsonUtil.EXTRACTED_EXPRESSIONS
- much smaller than other two, but still using noticeable amount of memory (in one heap dump it was around 10MB)There are other caches that should probably also be handled, but they are far from critical.
The question is how to do this - UnifiedMap is nice because it saves a lot of memory compared to other map implementations. So ideally we'd keep it and clean data from it. One simple brute-force solution could be to just recreate cache maps once a day. This would cause a spike in CPU usage for few seconds (or a bit more), until fresh entries get populated into newly created maps.