Module dlib.core.memory

Tools for manual memory management

New/Delete for classes, structs and arrays. It utilizes dlib.memory for actual memory allocation, so it is possible to switch allocator that is being used. By default, dlib.memory.mallocator.Mallocator is used.

Module includes a simple memory profiler that can be turned on with enableMemoryProfiler function. If active, it will store information about every allocation (type and size), and will mark those which are leaked (haven't been deleted).

Functions

NameDescription
allocatedMemory() Returns current amount of allocated memory in bytes. This is 0 at program start
enableMemoryProfiler(mode) Enables or disables memory profiler
globalAllocator() Returns current global Allocator that is used by New and Delete
globalAllocator(a) Sets global Allocator that is used by New and Delete
printMemoryLeaks() Prints leaked allocations if memory profiler is enabled, otherwise does nothing
printMemoryLog() Prints full allocation list if memory profiler is enabled, otherwise does nothing

Aliases

NameTypeDescription
Delete Destroys an object of type T previously created by New and calls its destructor if necessary.
New Creates an object of type T and calls its constructor if necessary.