A class for managing memory segments within a memory allocation.
More...
#include <MemoryAllocation.h>
|
| | MemoryAllocation (void *ptr, size_t size, size_t alignment=1) |
| |
| template<class T > |
| std::pair< T *, size_t > | Alloc (size_t size) |
| |
| std::pair< void *, size_t > | Alloc (size_t size) |
| |
| std::pair< void *, size_t > | AllocLargestSegment () |
| | Returns the largest free segment. More...
|
| |
| template<class T > |
| void | Free (const std::pair< T *, size_t > &segment) |
| | Frees a previously returned segment. More...
|
| |
| void | Free (const std::pair< void *, size_t > &segment) |
| | Frees a previously returned segment. More...
|
| |
| size_t | MaxUsed () const |
| | Returns the peak memory usage in bytes. More...
|
| |
| size_t | Alignment () const |
| | Returns the alignment in bytes. More...
|
| |
| const std::vector< std::pair< void *, size_t > > & | FreeSegments () const |
| | Returns the list of free segments. More...
|
| |
| void | PrintFreeSegments () const |
| | Prints all free segments. Meant for debugging. More...
|
| |
|
| template<class T > |
| static void | PrintSegment (const std::pair< T *, size_t > &s) |
| | Prints the segment. Meant for debugging. More...
|
| |
A class for managing memory segments within a memory allocation.
◆ MemoryAllocation()
| cloudViewer::ml::impl::MemoryAllocation::MemoryAllocation |
( |
void * |
ptr, |
|
|
size_t |
size, |
|
|
size_t |
alignment = 1 |
|
) |
| |
|
inline |
Creates a MemoryAllocation object that manages memory segments within a memory allocation.
- Parameters
-
| ptr | Pointer to the beginning of the memory. |
| size | Size of the memory. |
| alignment | The alignment for returned segments. |
References size.
◆ Alignment()
| size_t cloudViewer::ml::impl::MemoryAllocation::Alignment |
( |
| ) |
const |
|
inline |
Returns the alignment in bytes.
◆ Alloc() [1/2]
template<class T >
| std::pair<T*, size_t> cloudViewer::ml::impl::MemoryAllocation::Alloc |
( |
size_t |
size | ) |
|
|
inline |
Returns a memory segment with size for type T. Returns the pointer and the size in number of elements T. May return the pair (nullptr,0) if the allocation is not possible.
References size.
Referenced by AllocLargestSegment().
◆ Alloc() [2/2]
| std::pair<void*, size_t> cloudViewer::ml::impl::MemoryAllocation::Alloc |
( |
size_t |
size | ) |
|
|
inline |
Returns a memory segment with size in bytes. May return the pair (nullptr,0) if the allocation is not possible.
References size.
◆ AllocLargestSegment()
| std::pair<void*, size_t> cloudViewer::ml::impl::MemoryAllocation::AllocLargestSegment |
( |
| ) |
|
|
inline |
Returns the largest free segment.
References Alloc(), and size.
◆ Free() [1/2]
template<class T >
| void cloudViewer::ml::impl::MemoryAllocation::Free |
( |
const std::pair< T *, size_t > & |
segment | ) |
|
|
inline |
Frees a previously returned segment.
References size.
◆ Free() [2/2]
| void cloudViewer::ml::impl::MemoryAllocation::Free |
( |
const std::pair< void *, size_t > & |
segment | ) |
|
|
inline |
Frees a previously returned segment.
References count, and for().
◆ FreeSegments()
| const std::vector<std::pair<void*, size_t> >& cloudViewer::ml::impl::MemoryAllocation::FreeSegments |
( |
| ) |
const |
|
inline |
Returns the list of free segments.
◆ MaxUsed()
| size_t cloudViewer::ml::impl::MemoryAllocation::MaxUsed |
( |
| ) |
const |
|
inline |
Returns the peak memory usage in bytes.
◆ PrintFreeSegments()
| void cloudViewer::ml::impl::MemoryAllocation::PrintFreeSegments |
( |
| ) |
const |
|
inline |
Prints all free segments. Meant for debugging.
References PrintSegment().
◆ PrintSegment()
template<class T >
| static void cloudViewer::ml::impl::MemoryAllocation::PrintSegment |
( |
const std::pair< T *, size_t > & |
s | ) |
|
|
inlinestatic |
The documentation for this class was generated from the following file: