Re: GC pros and cons
Re: GC pros and cons
- Subject: Re: GC pros and cons
- From: Michael Ash <email@hidden>
- Date: Thu, 25 Jun 2009 23:26:16 -0400
On Thu, Jun 25, 2009 at 4:14 PM, Peter Ammon<email@hidden> wrote:
> 2) Require that malloc be robust against multiple free()s on the same
> pointer
>
> The second solution is a lot easier to implement.
Can you elaborate on this? Thinking about how to accomplish this, it
seems like an extremely difficult problem. The only thing I've been
able to come up with that would work would be to make all pointers be
implemented as an address plus a counter. Then when you call free, it
checks your pointer's counter against the latest one allocated there,
and if your counter is stale, it does nothing. This would be a massive
change to the language that would break binary compatibility with
everything and bloat pointer sizes hugely, since it would really
require at least 64 bits for the counter to be properly robust.
Is there some easy solution to this that I'm overlooking? Silently
returning if you pass a freed block is not sufficient, because that
block could have been reused by the time the second free() happens,
causing a chunk of memory owned by someone else to be spontaneously
destroyed.
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden