%u <wfunct...@hotmail.com> wrote:

Hi,

There's a question that's been lurking in the back of my mind ever since I learned about D:

How does the GC distinguish code from data when determining the objects to collect? (E.g. void[] from uint[], size_t from void*, etc.?)

This is hardly the code/data dualism (data can easily hold pointers), but
simply POD/pointers.


If I have a large uint[], it's practically guaranteed to have data that looks like pointers, and that might cause memory leaks.

If you have allocated a large uint[], most likely ìt will be flagged
NO_SCAN, meaning it has no pointers in it, and the GC will ignore it.


Furthermore, if the GC moves
things around, it would corrupt my data. How is this handled?

The current GC does not move things. One could write such a GC for D (I
believe), and in such a case data would be marked NO_MOVE if for whatever
reason it cannot be moved.


--
Simen

Reply via email to