Main MRPT website > C++ reference
MRPT logo
Classes | Defines | Functions
Memory utilities
[mrpt-base]
Collaboration diagram for Memory utilities:

Classes

class  mrpt::system::CGenericMemoryPool
 A generic system for versatile memory pooling. More...

Defines

#define mrpt_alloca(nBytes)   ::malloc( nBytes )
 In platforms and compilers with support to "alloca", allocate a memory block on the stack; if alloca is not supported, it is emulated as a normal "malloc" - NOTICE: Since in some platforms alloca will be emulated with malloc, alloca_free MUST BE ALWAYS CALLED to avoid memory leaks.
#define mrpt_alloca_free(mem_block)   free(mem_block)
 This method must be called to "free" each memory block allocated with "system::alloca": If the block was really allocated in the stack, no operation is actually performed, otherwise it will be freed from the heap.

Functions

unsigned long BASE_IMPEXP mrpt::system::getMemoryUsage ()
 Returns the memory occupied by this process, in bytes.
void BASE_IMPEXP * mrpt::system::os::aligned_malloc (size_t bytes, size_t alignment)
 Returns an aligned memory block.
void * mrpt::system::os::aligned_calloc (size_t bytes, size_t alignment)
 Identical to aligned_malloc, but it zeroes the reserved memory block.
void BASE_IMPEXP * mrpt::system::os::aligned_realloc (void *old_ptr, size_t bytes, size_t alignment)
 Frees a memory block reserved by aligned_malloc.
void BASE_IMPEXP mrpt::system::os::aligned_free (void *p)
 Frees a memory block reserved by aligned_malloc.
template<typename _Tp >
_Tp * mrpt::system::os::align_ptr (_Tp *ptr, int n=(int) sizeof(_Tp))
 Returns a pointer a bit forward in memory so it's aligned for the given boundary size.
template<int bytes>
bool mrpt::system::is_aligned (const void *ptr)
template<>
bool mrpt::system::is_aligned< 8 > (const void *ptr)
template<>
bool mrpt::system::is_aligned< 16 > (const void *ptr)

Define Documentation

#define mrpt_alloca (   nBytes)    ::malloc( nBytes )

In platforms and compilers with support to "alloca", allocate a memory block on the stack; if alloca is not supported, it is emulated as a normal "malloc" - NOTICE: Since in some platforms alloca will be emulated with malloc, alloca_free MUST BE ALWAYS CALLED to avoid memory leaks.

This method MUST BE a macro rather than a function in order to operate on the caller's stack.

See also:
mrpt_alloca_free

Definition at line 56 of file memory.h.

#define mrpt_alloca_free (   mem_block)    free(mem_block)

This method must be called to "free" each memory block allocated with "system::alloca": If the block was really allocated in the stack, no operation is actually performed, otherwise it will be freed from the heap.

This method MUST BE a macro rather than a function in order to operate on the caller's stack.

See also:
mrpt_alloca

Definition at line 71 of file memory.h.


Function Documentation

template<typename _Tp >
_Tp* mrpt::system::os::align_ptr ( _Tp *  ptr,
int  n = (int)sizeof(_Tp) 
) [inline]

Returns a pointer a bit forward in memory so it's aligned for the given boundary size.

Note:
Function copied from OpenCV with a different name to avoid conflicts.

Definition at line 111 of file memory.h.

void* mrpt::system::os::aligned_calloc ( size_t  bytes,
size_t  alignment 
) [inline]

Identical to aligned_malloc, but it zeroes the reserved memory block.

Definition at line 89 of file memory.h.

References mrpt::system::os::aligned_malloc().

Referenced by mrpt::math::CMatrixTemplate< TPoint3D >::realloc().

void BASE_IMPEXP mrpt::system::os::aligned_free ( void *  p) [inline]

Frees a memory block reserved by aligned_malloc.

See also:
aligned_malloc

Definition at line 225 of file Core.

Referenced by mrpt::math::CMatrixTemplate< TPoint3D >::realloc().

void BASE_IMPEXP* mrpt::system::os::aligned_malloc ( size_t  bytes,
size_t  alignment 
)

Returns an aligned memory block.

Parameters:
alignmentThe desired alignment, typ. 8 or 16 bytes. 1 means no alignment required. It must be a power of two.
See also:
aligned_free, aligned_realloc, aligned_calloc
Note:
Based on code by William Chan

Referenced by mrpt::system::os::aligned_calloc().

void BASE_IMPEXP* mrpt::system::os::aligned_realloc ( void *  old_ptr,
size_t  bytes,
size_t  alignment 
) [inline]

Frees a memory block reserved by aligned_malloc.

Parameters:
alignmentThe desired alignment, typ. 8 or 16 bytes. 1 means no alignment required. If old_ptr is NULL, a new block will be reserved from scratch.
See also:
aligned_malloc, aligned_free

Definition at line 247 of file Core.

Referenced by mrpt::math::CMatrixTemplate< TPoint3D >::realloc().

unsigned long BASE_IMPEXP mrpt::system::getMemoryUsage ( )

Returns the memory occupied by this process, in bytes.

template<int bytes>
bool mrpt::system::is_aligned ( const void *  ptr)
template<>
bool mrpt::system::is_aligned< 16 > ( const void *  ptr) [inline]

Definition at line 125 of file memory.h.

template<>
bool mrpt::system::is_aligned< 8 > ( const void *  ptr) [inline]

Definition at line 124 of file memory.h.




Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011