Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
|
Memory limiter. This class can be used to keep track of memory being consumed. This is done through the acquire and release methods. The class is used within classes such as LimitedPool, LimitedArena. More...
#include <memory_limiter.h>
Public Member Functions | |
MemoryLimiter (const char *name, size_t max_bytes) | |
Initialize memory limiter. max_bytes is the maximum total amount of memory that can be acquired. If 0, then there is no limit, in which case, only tracking will be performed. More... | |
~MemoryLimiter () | |
Destroy memory limiter. This will panic if memory is still tracked as acquired. More... | |
ROC_ATTR_NODISCARD bool | acquire (size_t num_bytes) |
Track acquired memory. More... | |
void | release (size_t num_bytes) |
Track released memory. This will panic if we are releasing more than what is currently acquired. More... | |
size_t | num_acquired () |
Get number of bytes currently acquired. More... | |
Memory limiter. This class can be used to keep track of memory being consumed. This is done through the acquire and release methods. The class is used within classes such as LimitedPool, LimitedArena.
Definition at line 27 of file memory_limiter.h.
|
explicit |
Initialize memory limiter. max_bytes
is the maximum total amount of memory that can be acquired. If 0, then there is no limit, in which case, only tracking will be performed.
roc::core::MemoryLimiter::~MemoryLimiter | ( | ) |
Destroy memory limiter. This will panic if memory is still tracked as acquired.
ROC_ATTR_NODISCARD bool roc::core::MemoryLimiter::acquire | ( | size_t | num_bytes | ) |
Track acquired memory.
size_t roc::core::MemoryLimiter::num_acquired | ( | ) |
Get number of bytes currently acquired.
void roc::core::MemoryLimiter::release | ( | size_t | num_bytes | ) |
Track released memory. This will panic if we are releasing more than what is currently acquired.