yage.core.memory
- class
Memory
;
- This class allows allocating and freeing memory from a stack in a last-in/first-out manner,
A separate stack is used for each thread, allowing complete thread safety.
D's built-in new/delete is faster for allocations less than 50 bytes, but for large
allocations, this is much faster.
Example:
long[] foo = Memory.allocate!(long)(50);
Bar[] bar = Memory.allocate!(Bar)(10);
...
Memory.free(bar);
Memory.free(foo); // must be freed in reverse order.
- T[]
allocate
(T)(int length);
- Get a new array of type T.
Params:
- void
free
(T)(T[] data);
- Free a previously allocated array.
- static void
freeAll
();
- Free all memory for the current thread.
|