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

Members

Aliases

Delete
alias Delete = deallocate

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

New
alias New = allocate

Creates an object of type T and calls its constructor if necessary.

Functions

allocate
T allocate(A args, string file, int line)
Undocumented in source. Be warned that the author may not have intended to support it.
allocate
T* allocate(A args, string file, int line)
Undocumented in source. Be warned that the author may not have intended to support it.
allocate
T allocate(size_t length, string file, int line)
Undocumented in source. Be warned that the author may not have intended to support it.
allocate
T allocate(A args)
Undocumented in source. Be warned that the author may not have intended to support it.
allocate
T* allocate(A args)
Undocumented in source. Be warned that the author may not have intended to support it.
allocate
T allocate(size_t length)
Undocumented in source. Be warned that the author may not have intended to support it.
allocatedMemory
ulong allocatedMemory()

Returns current amount of allocated memory in bytes. This is 0 at program start

deallocate
void deallocate(T obj)
Undocumented in source. Be warned that the author may not have intended to support it.
deallocate
void deallocate(T obj)
Undocumented in source. Be warned that the author may not have intended to support it.
deallocate
void deallocate(T* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
enableMemoryProfiler
void enableMemoryProfiler(bool mode)

Enables or disables memory profiler

globalAllocator
Allocator globalAllocator()

Returns current global Allocator that is used by New and Delete

globalAllocator
void globalAllocator(Allocator a)

Sets global Allocator that is used by New and Delete

printMemoryLeaks
void printMemoryLeaks()

Prints leaked allocations if memory profiler is enabled, otherwise does nothing

printMemoryLog
void printMemoryLog()

Prints full allocation list if memory profiler is enabled, otherwise does nothing

Interfaces

Freeable
interface Freeable
Undocumented in source.

Manifest constants

psize
enum psize;
Undocumented in source.

Structs

AllocationRecord
struct AllocationRecord
Undocumented in source.

Meta

Authors

Timur Gafarov