12 #ifndef ROC_CORE_MEMORY_LIMITER_H_
13 #define ROC_CORE_MEMORY_LIMITER_H_
52 const size_t max_bytes_;
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Memory limiter. This class can be used to keep track of memory being consumed. This is done through t...
size_t num_acquired()
Get number of bytes currently acquired.
ROC_ATTR_NODISCARD bool acquire(size_t num_bytes)
Track acquired memory.
MemoryLimiter(const char *name, size_t max_bytes)
Initialize memory limiter. max_bytes is the maximum total amount of memory that can be acquired....
~MemoryLimiter()
Destroy memory limiter. This will panic if memory is still tracked as acquired.
void release(size_t num_bytes)
Track released memory. This will panic if we are releasing more than what is currently acquired.
Base class for non-copyable objects.
Commonly used types and functions.