Flutter Engine
The Flutter Engine
|
#include <GrMemoryPool.h>
Public Member Functions | |
~GrMemoryPool () | |
void | operator delete (void *p) |
void * | allocate (size_t size) |
void | release (void *p) |
bool | isEmpty () const |
void | reportLeaks () const |
size_t | size () const |
size_t | preallocSize () const |
void | resetScratchSpace () |
Static Public Member Functions | |
static std::unique_ptr< GrMemoryPool > | Make (size_t preallocSize, size_t minAllocSize) |
Static Public Attributes | |
static constexpr size_t | kAlignment = alignof(std::max_align_t) |
static constexpr size_t | kMinAllocationSize = 1 << 10 |
Allocates memory in blocks and parcels out space in the blocks for allocation requests. It is optimized for allocate / release speed over memory efficiency. The interface is designed to be used to implement operator new and delete overrides. All allocations are expected to be released before the pool's destructor is called. Allocations will be aligned to sizeof(std::max_align_t).
All allocated objects must be released back to the memory pool before it can be destroyed.
Definition at line 31 of file GrMemoryPool.h.
GrMemoryPool::~GrMemoryPool | ( | ) |
Definition at line 43 of file GrMemoryPool.cpp.
void * GrMemoryPool::allocate | ( | size_t | size | ) |
Allocates memory. The memory must be freed with release() before the GrMemoryPool is deleted.
Definition at line 67 of file GrMemoryPool.cpp.
|
inline |
Returns true if there are no unreleased allocations.
Definition at line 73 of file GrMemoryPool.h.
|
static |
Prealloc size is the amount of space to allocate at pool creation time and keep around until pool destruction. The min alloc size is the smallest allowed size of additional allocations. Both sizes are adjusted to ensure that they are at least as large as kMinAllocationSize and less than SkBlockAllocator::kMaxAllocationSize.
Both sizes are what the pool will end up allocating from the system, and portions of the allocated memory is used for internal bookkeeping.
Definition at line 23 of file GrMemoryPool.cpp.
|
inline |
Definition at line 59 of file GrMemoryPool.h.
|
inline |
Returns the preallocated size of the GrMemoryPool
Definition at line 95 of file GrMemoryPool.h.
void GrMemoryPool::release | ( | void * | p | ) |
p must have been returned by allocate().
Definition at line 102 of file GrMemoryPool.cpp.
void GrMemoryPool::reportLeaks | ( | ) | const |
In debug mode, this reports the IDs of unfreed nodes via SkDebugf
. This reporting is also performed automatically whenever a GrMemoryPool is destroyed. In release mode, this method is a no-op.
Definition at line 50 of file GrMemoryPool.cpp.
|
inline |
Frees any scratch blocks that are no longer being used.
Definition at line 104 of file GrMemoryPool.h.
|
inline |
Returns the total allocated size of the GrMemoryPool minus any preallocated amount
Definition at line 90 of file GrMemoryPool.h.
|
staticconstexpr |
Definition at line 40 of file GrMemoryPool.h.
|
inlinestaticconstexpr |
Definition at line 44 of file GrMemoryPool.h.