Open3D (C++ API)  0.18.0+5c982c7
Public Member Functions | Static Public Member Functions
open3d::core::MemoryCache Class Reference

Public Member Functions

 MemoryCache ()=default
 
 MemoryCache (const MemoryCache &)=delete
 
MemoryCacheoperator= (const MemoryCache &)=delete
 
void * Malloc (size_t byte_size)
 
void Free (void *ptr)
 
void Acquire (void *ptr, size_t byte_size, const std::shared_ptr< MemoryManagerDevice > &device_mm)
 Acquires ownership of the new real allocated blocks. More...
 
std::vector< std::pair< void *, std::shared_ptr< MemoryManagerDevice > > > Release (size_t byte_size)
 
std::vector< std::pair< void *, std::shared_ptr< MemoryManagerDevice > > > ReleaseAll ()
 Releases ownership of all unused real allocated blocks. More...
 
size_t Size () const
 Returns the number of allocated real blocks. More...
 
bool Empty () const
 True if the set of allocated real blocks is empty, false otherwise. More...
 

Static Public Member Functions

static size_t AlignByteSize (size_t byte_size, size_t alignment=8)
 

Constructor & Destructor Documentation

◆ MemoryCache() [1/2]

open3d::core::MemoryCache::MemoryCache ( )
default

◆ MemoryCache() [2/2]

open3d::core::MemoryCache::MemoryCache ( const MemoryCache )
delete

Member Function Documentation

◆ Acquire()

void open3d::core::MemoryCache::Acquire ( void *  ptr,
size_t  byte_size,
const std::shared_ptr< MemoryManagerDevice > &  device_mm 
)
inline

Acquires ownership of the new real allocated blocks.

◆ AlignByteSize()

static size_t open3d::core::MemoryCache::AlignByteSize ( size_t  byte_size,
size_t  alignment = 8 
)
inlinestatic

Computes an internal byte size that ensures a proper alignment of the real and virtual blocks.

◆ Empty()

bool open3d::core::MemoryCache::Empty ( ) const
inline

True if the set of allocated real blocks is empty, false otherwise.

◆ Free()

void open3d::core::MemoryCache::Free ( void *  ptr)
inline

Frees memory by moving the corresponding block to the set of free virtual blocks. Consecutive free virtual blocks belonging to the same real block are merged together.

◆ Malloc()

void* open3d::core::MemoryCache::Malloc ( size_t  byte_size)
inline

Allocates memory from the set of free virtual blocks. Returns nullptr if no suitable block was found.

◆ operator=()

MemoryCache& open3d::core::MemoryCache::operator= ( const MemoryCache )
delete

◆ Release()

std::vector<std::pair<void*, std::shared_ptr<MemoryManagerDevice> > > open3d::core::MemoryCache::Release ( size_t  byte_size)
inline

Releases ownership of unused real allocated blocks whose sizes sum up to the requested byte size. Strategy:

  • Best single fit: argmin_x { x.byte_size_ >= byte_size }.
  • If not found, use next-best fit and repeat.

◆ ReleaseAll()

std::vector<std::pair<void*, std::shared_ptr<MemoryManagerDevice> > > open3d::core::MemoryCache::ReleaseAll ( )
inline

Releases ownership of all unused real allocated blocks.

◆ Size()

size_t open3d::core::MemoryCache::Size ( ) const
inline

Returns the number of allocated real blocks.


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