A class for local memory management.
More...
#include <kalloc.hh>
A class for local memory management.
Use this only locally, as it is not thread-safe. If unsure, use Kalloc.
Definition at line 186 of file kalloc.hh.
|
| | KallocUnlocked (int node_, int align_=64, size_t blocksize_=2 *1024 *1024, bool checking=true) |
| | Constructor. More...
|
| |
| void * | alloc (size_t n) |
| | Allocates n bytes of memory. More...
|
| |
| void | free (void *p, size_t n) |
| | Releases memory range. More...
|
| |
| void | reserve (size_t n, size_t k) |
| | Tells the allocator that subsequently several blocks of the same size will be requested. More...
|
| |
| size_t | alignment () const |
| | Reports the alignment size. More...
|
| |
| std::ostream & | print (std::ostream &out) const |
| | Prints memory management statistics to the given stream. More...
|
| |
◆ KallocUnlocked()
| Kaskade::KallocUnlocked::KallocUnlocked |
( |
int |
node_, |
|
|
int |
align_ = 64, |
|
|
size_t |
blocksize_ = 2*1024*1024, |
|
|
bool |
checking = true |
|
) |
| |
|
inline |
Constructor.
- Parameters
-
| node | The NUMA node on which to allocate memory. |
| align | The alignment of the memory to return. Has to be a power of 2, and significantly below blocksize. Defaults to common cache line size of 64 bytes. |
| blocksize | The size of memory blocks to be requested from libnuma. Has to be a multiple of \( 4096 \). Defaults to 2^21, which is two MB. |
| checking | If true, performs additional usage sanity checks for detecting memory management bugs. |
Definition at line 196 of file kalloc.hh.
◆ alignment()
| size_t Kaskade::Kalloc::alignment |
( |
| ) |
const |
|
inlineinherited |
Reports the alignment size.
Definition at line 119 of file kalloc.hh.
◆ alloc()
| void * Kaskade::KallocUnlocked::alloc |
( |
size_t |
n | ) |
|
|
inline |
Allocates n bytes of memory.
If n exceeds the alignment size, the returned memory range is guaranteed to be aligned as to the value specified on construction.
The method is NOT thread-safe.
- Parameters
-
| n | requested memory size in bytes. |
Definition at line 208 of file kalloc.hh.
◆ allocUnlocked()
| void * Kaskade::Kalloc::allocUnlocked |
( |
size_t |
n | ) |
|
|
protectedinherited |
Allocates n bytes of memory.
This method is NOT thread-safe. Use this only if you know exactly there's only one thread accessing the allocator.
Referenced by alloc().
◆ free()
| void Kaskade::KallocUnlocked::free |
( |
void * |
p, |
|
|
size_t |
n |
|
) |
| |
|
inline |
Releases memory range.
The method is NOT thread-safe.
- Parameters
-
| p | pointer returned previously by alloc |
| n | memory size as requrested in the corresponding call to alloc |
Definition at line 218 of file kalloc.hh.
◆ freeUnlocked()
| void Kaskade::Kalloc::freeUnlocked |
( |
void * |
p, |
|
|
size_t |
n |
|
) |
| |
|
protectedinherited |
Releases memory range.
This method is NOT thread-safe. Use this only if you know exactly there's only one thread accessing the allocator.
Referenced by free().
◆ print()
| std::ostream & Kaskade::Kalloc::print |
( |
std::ostream & |
out | ) |
const |
|
inherited |
Prints memory management statistics to the given stream.
◆ reserve()
| void Kaskade::Kalloc::reserve |
( |
size_t |
n, |
|
|
size_t |
k |
|
) |
| |
|
inherited |
Tells the allocator that subsequently several blocks of the same size will be requested.
This is a hint to the allocator that can improve its performance.
- Parameters
-
| n | the size of the memory blocks to be requested |
| k | the number of the memory blocks to be requested |
The documentation for this class was generated from the following file: