Implement API for getting memory allocation statistics
This PR implements a API for retrieving offheap memory allocation statistics.
Fastcache allocates the offheap memory "manually" in order to mitigate the overhead of golang garbage collection. However it also means this part of memory won't be tracked by golang standard metrics.
In order to accurately know how much memory is used by our application, we need this additional statistics to sum up the standard memory usage.
@valyala please take a look?
For the record, our need for the metrics arose from a missed Reset operation which resulted in an eventual OOM. None of our monitoring systems detected the issue ahead of time since the memory was not reported by Go. Would be nice to be able to track it at least explicitly to have an early warning for similar issues in the future.
I'm curious how you got an OOM. Did you set maxBytes higher than the available memory?
No, we had ephemeral cache instances and a refactor lost the Reset when the outer temporary object got cleaned up.
@valyala any chance to take a look?