Regionerator Memory leak
Regionerator plugin causes steady heap growth traced to instances held in a BatchExpiringLoadingCache. Heap dump and screenshots are attached below.
Steps to reproduce:
- Start server with Regionerator enabled on a busy map, with default cache settings.
- Let server run under normal player activity for a day.
- Observe heap usage rising over time, GC not freeing cached entries.
Observed behavior: Heap usage increases continuously, many Regionerator-related objects remain live in the BatchExpiringLoadingCache according to heap dump. Plugin memory use does not drop after region unloads or player logouts.
Expected behavior: Cache entries expire and are released in a timely manner, overall heap stabilizes under steady load.
Heap dump and screenshots are attached below.
MEMORY HEAP DUMP: https://drive.google.com/file/d/1Pe_h-ZYYt7HSxNGETjMxo6ywqccSSQYN/view?usp=drivesdk
If you're seeing growth of entries, you probably need to adjust your cache settings to suit your server's needs. You can check the state of the cache and its unload queue with /regionerator cache. If the queue isn't overloaded, presumably the retention duration is too long for your server's level of activity. If the queue is overloaded, increase the batch size.
See the settings here: https://github.com/Jikoo/Regionerator/wiki/Configuration#cache
Note that the writeup for batch delay is a bit misleading, because it only takes effect if the batch is not entirely full. An over-full queue will ignore it.
I don't mind looking into this some more, but frankly, if you're a larger-than-average server, you probably just want to make tweaks to improve performance for your particular case. Also, was this during or shortly after a cycle? If that's the case, exceeding the cache soft cap isn't really surprising at all. It probably wouldn't hurt to revisit the default cache settings either way though.