www.digitalmars.com         C & C++   DMDScript  

D - How is 'delete' implemented?

reply "Jeroen van Bemmel" <anonymous somewhere.com> writes:
Is it a hint to the garbage collector to do a check, starting with the
object on which delete is called?
Mar 07 2003
parent "Walter" <walter digitalmars.com> writes:
"Jeroen van Bemmel" <anonymous somewhere.com> wrote in message
news:b4amd9$25ai$1 digitaldaemon.com...
 Is it a hint to the garbage collector to do a check, starting with the
 object on which delete is called?

No, it isn't a hint to the gc. It instructs the gc to run the destructor (if any) on the object, and then mark the object as 'free'. The gc does not do any checks. If you left any dangling pointers to it, you've got a pointer bug. As such, delete is a more advanced technique and should be used with caution. It's in the language so people can tune their code for performance.
Mar 07 2003