std.stringbuffer

Sean Kelly sean at invisibleduck.org
Wed Apr 30 00:21:29 PDT 2008


== Quote from Janice Caron (caron800 at googlemail.com)'s article
> I would support the addition of some function like
>     gc.minimise(char[])
> which returned all the unused space following the end of the array
> back to the gc, without any copying of the used part. I wouldn't be
> able to write that though - the gc is not my area of expertise.

This would only work for large arrays I'm afraid, given the GC
implementation for D--it uses fixed-size blocks until the block
size is 4096 bytes or larger.  Also, the shrinking would be done
in chunks of 4096 bytes, so a fairly substantial size change would
have to occur for anything to happen at all.  That said, things get
a lot easier if moving the block is allowed.  Tango even exposes
a GC.realloc() routine which will do this for you.


Sean



More information about the Digitalmars-d mailing list