Are heap objects never moved by the garbage collector?
sclytrack
reckless at hotmail.com
Sat Jun 1 01:11:04 PDT 2013
On Friday, 31 May 2013 at 16:31:39 UTC, Carl Sturtivant wrote:
>
> "The D Programming Language" (TDPL) p.178 asserts the following.
>
> "The objects themselves stay put, that is their locations in
> memory never change after creation."
>
> I take this to mean that the D garbage collector doesn't move
> live objects and adjust all references to them the way that
> some garbage collectors do. That is to say, the addresses of
> objects are not changed by the garbage collector.
>
> Does D guarantee this?
No. Quoted from the D website:
http://dlang.org/garbage.html
"Although D does not currently use a moving garbage collector, by
following the rules listed above one can be implemented. No
special action is required to pin objects. A moving collector
will only move objects for which there are no ambiguous
references, and for which it can update those references. All
other objects will be automatically pinned. "
I'll assume you can not move immutable pointers. Immutable
pointers are not mentioned on that page. (except in the index
left :)
More information about the Digitalmars-d-learn
mailing list