Open3D (C++ API)  0.18.0+252c867
Public Member Functions | Static Public Member Functions
open3d::ml::impl::MemoryAllocation Class Reference

A class for managing memory segments within a memory allocation. More...

#include <MemoryAllocation.h>

Public Member Functions

 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...
 

Static Public Member Functions

template<class T >
static void PrintSegment (const std::pair< T *, size_t > &s)
 Prints the segment. Meant for debugging. More...
 

Detailed Description

A class for managing memory segments within a memory allocation.

Constructor & Destructor Documentation

◆ MemoryAllocation()

open3d::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
ptrPointer to the beginning of the memory.
sizeSize of the memory.
alignmentThe alignment for returned segments.

Member Function Documentation

◆ Alignment()

size_t open3d::ml::impl::MemoryAllocation::Alignment ( ) const
inline

Returns the alignment in bytes.

◆ Alloc() [1/2]

template<class T >
std::pair<T*, size_t> open3d::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.

◆ Alloc() [2/2]

std::pair<void*, size_t> open3d::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.

◆ AllocLargestSegment()

std::pair<void*, size_t> open3d::ml::impl::MemoryAllocation::AllocLargestSegment ( )
inline

Returns the largest free segment.

◆ Free() [1/2]

template<class T >
void open3d::ml::impl::MemoryAllocation::Free ( const std::pair< T *, size_t > &  segment)
inline

Frees a previously returned segment.

◆ Free() [2/2]

void open3d::ml::impl::MemoryAllocation::Free ( const std::pair< void *, size_t > &  segment)
inline

Frees a previously returned segment.

◆ FreeSegments()

const std::vector<std::pair<void*, size_t> >& open3d::ml::impl::MemoryAllocation::FreeSegments ( ) const
inline

Returns the list of free segments.

◆ MaxUsed()

size_t open3d::ml::impl::MemoryAllocation::MaxUsed ( ) const
inline

Returns the peak memory usage in bytes.

◆ PrintFreeSegments()

void open3d::ml::impl::MemoryAllocation::PrintFreeSegments ( ) const
inline

Prints all free segments. Meant for debugging.

◆ PrintSegment()

template<class T >
static void open3d::ml::impl::MemoryAllocation::PrintSegment ( const std::pair< T *, size_t > &  s)
inlinestatic

Prints the segment. Meant for debugging.


The documentation for this class was generated from the following file: