Memory utilities

Header: #include <mrpt/system/memory.h>.

Library: [mrpt-system]

// classes

template <class DATA_PARAMS, class POOLABLE_DATA>
class mrpt::system::CGenericMemoryPool;

// global functions

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

template <
    std::size_t alignment,
    typename T,
    typename = std::enable_if_t<std::is_pointer<T>::value>
    >
bool mrpt::system::is_aligned(T ptr);

// macros

#define mrpt_alloca(nBytes)
#define mrpt_alloca_free(mem_block)

Global Functions

unsigned long mrpt::system::getMemoryUsage()

Returns the memory occupied by this process, in bytes.

Macros

#define mrpt_alloca(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

#define mrpt_alloca_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