D-
Jonathan M Davis
jmdavisProg at gmx.com
Sat Feb 11 17:00:42 PST 2012
On Sunday, February 12, 2012 01:40:50 Zachary Lund wrote:
> Btw, I'm not very fluent in the inner workings of a garbage
> collector implementation but how does one go about concatenating
> to an array in a garbage collector as compared to manual memory
> management? I believe array concatenation can be done in
> std::vector with the insert() function just fine. Isn't it as
> simple as determining both array sizes and allocating enough
> memory for both arrays? I could be oversimplifying things...
Read this:
http://www.dsource.org/projects/dcollections/wiki/ArrayArticle
Appending to vectors is very different from appending to dynamic arrays because
dynamic arrays do _not_ own their own memory (the GC does) and not only could
other slices refer the same memory (in which case, you can't just free that
memory when an array gets reallocated due to running out of space to append
to), but they could already refer to the memory one past the end of the array,
making it so that it can't expand into that memory.
Slices change the entire equation. And the way slices are designed, they
require the GC.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list