Array Capacity Field
dsimcha
dsimcha at yahoo.com
Wed May 7 13:51:51 PDT 2008
According to the Phobos docs, std.gc.capacity "Returns capacity (size of the
memory block) that p points to the beginning of. If p does not point into the gc
memory pool, or does not point to the beginning of an allocated memory block, 0 is
returned." I had looked through this before.
It also doesn't appear that writing my own function to do this works:
void capacity(T)(ref T[] array, uint newCapacity) {
if(newCapacity < array.length) {
array.length=newCapacity;
}
std.gc.realloc(array.ptr, T.sizeof*newCapacity);
}
When I use this after allocating a huge array, and then run a fullCollect() and a
minimize(), the memory usage of my programs appear not to go down.
More information about the Digitalmars-d
mailing list