sematext / sematext-agent-java

Sematext Monitoring Agent
https://sematext.com/spm
Apache License 2.0
23 stars 9 forks source link

Periodically expunge entries from internal agent caches #53

Closed bsmid closed 5 years ago

bsmid commented 5 years ago

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:

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.

bsmid commented 5 years ago

Switched to Guava cache for 3 biggest caches.