[Gc] double frees
bruce.hoult at gmail.com
Mon Nov 15 17:52:39 PST 2004
On Mon, 15 Nov 2004 19:25:44 +0100, Hans Van den Eynden
<hans.vandeneynden at student.kuleuven.ac.be> wrote:
> That's it?? So there is no extra control to see that an object is already deleted?
> What will happen when I double delete an object?
Garbage collection is useful because it's not always easy to know when
a program is really finished with an object, so you don't know when to
call delete(). In the absence of garbage collection this can result
in memory leaks or double deletes.
If you have garbage collection then you'll only use explicit deletes
when you're really sure that the object is no longer needed, probably
because its lifetime is very simple to calculate. (And even then only
if it makes a significant difference to the memory use or speed of
Therefore double deletes should never happen if you are using a
More information about the Gc