Array Capacity Field

Sean Kelly sean at invisibleduck.org
Wed May 7 11:35:01 PDT 2008


== Quote from dsimcha (dsimcha at yahoo.com)'s article
> I know it's been talked about before, but what is the status of the array
> capacity field that's independent of length?  It would be useful to have such
> a thing, for example, when working on a program that uses multi-dimensional
> dynamic arrays to avoid excessive wasted space.  For example:
> void main () {
>     uint[][] Table;
>     //Read in a huge jagged table of data from a file.
>     //Do stuff that involves read-only access to Table[][] and
>     // requires a lot of memory.
> }
> The above might result in running out of memory due to the amount of wasted
> space in Table[][].  If there were a way to compact Table[][] once one knows
> it will not be appended to, this would solve a lot of problems.

Use std.gc.capacity() in Phobos and tango.core.Memory.GC.sizeOf() in Tango.


Sean



More information about the Digitalmars-d mailing list