Open abyss7 opened 1 week ago
Thanks for the pull request.
It's somewhat tricky to support a callback right here, since we're holding pageheap_lock
. We read stats about memory usage under that lock, and that plausibly seems like something a zero-argument callee might need to do.
For our internal use cases that need to track memory usage, we've had a lot of success with using callbacks on our sampled allocations: It allows the application to track memory usage with about 2MB of error either way and can be done without holding any locks. While we haven't (yet) open-sourced these APIs, is that something that would work for your use case?
This feature is useful i.e. to handle large heap allocations, pre-OOM state, or just signal about a certain size of heap.