Slices and GC
BLM
blm768 at gmail.com
Thu Apr 5 09:35:45 PDT 2012
On Thursday, 5 April 2012 at 15:30:45 UTC, Vladimir Panteleev
wrote:
>
> The GC can't really know which parts of the array you're using.
> For example, your only reference to the array might be a
> pointer, and you might be traversing the array in either
> direction, only keeping count of the remaining bytes until the
> array boundary.
>
> Consider .dup-ing the slices you're going to need, or using
> std.mmfile to map the file into memory - in that case, the OS
> won't load the unnecessary parts of the file into memory in the
> first place.
I had considered using .dup, but I wanted to minimize overhead. I
should probably look into std.mmfile or pull the data out in
smaller chunks that the GC can handle individually.
If the GC can distinguish between pointers and slices, it should
theoretically be able to prune an array that is only referenced
by slices, but I'm not sure how well that would fit into the
current GC system.
More information about the Digitalmars-d
mailing list