Re: GC memory leak - what is it?
Re: GC memory leak - what is it?
- Subject: Re: GC memory leak - what is it?
- From: Bill Bumgarner <email@hidden>
- Date: Mon, 04 Jan 2010 12:39:22 -0800
On Jan 4, 2010, at 11:50 AM, email@hidden wrote:
> A recent post mentioned the concept of GC memory leakage.
>
> How is is this defined? Is it merely a failure to nil out a rooted reference?
>
> man heap(1) makes reference to over-rooted objects.
> Are these merely objects with more than one root reference or is something else afoot?
Under GC, a memory leak will fall into one of two categories:
(1) An object was CFRetain'd, but never CFRelease'd. This is exactly like over-retaining an object in non-GC . Note that, in general, if you are using CFRetain under GC, it is only to work around a limitation somewhere or because of a design flaw. If you need to use CFRetain to work around something, please file a bug!
(2) A hard reference to an object that isn't cleaned up.
For example, many applications have a cache somewhere, typically key/value pairs. I have seen a number of these where, under non-GC, the cache never retained the values and was never pruned. Because the values were never retained, the values in the cache were released and deallocated, leaving behind a dangling value with a key that would no longer ever be accessed. In the move to GC, this created a leak in that the cache would often default to a strong reference. Lesson; prune your caches!
It isn't so much thinking of it as a reference that needs to be nil'd out as much as it is a need to properly disconnect a subgraph of objects from the live object graph in an application such that the subgraph is collected. That is, "nil'ing out references" is a fix for a symptom where the overarching problem is one of properly managing the connectivity of the object graph within the application.
b.bum
_______________________________________________
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