On 28 Mar 2010, at 02:14, Quincey Morris wrote: > On Mar 27, 2010, at 16:51, Noah Desch wrote: > >> If you are *not* using getters and setters but instead have myFields >> declared as: >> >> @interface MyClass >> { >> NSMutableDictionary *myFields; >> } >> >> and you use the above line of code, and subsequently release myFields in >> your dealloc method.... this would *not* be a memory leak, correct? > > Correct (except that the 'self.' syntax won't work.) The OP had exactly the > code pattern you describe: > > ... > if (myFields == nil) > myFields = [[NSMutableArray alloc] init]; > ... > > - (void) dealloc { > [myFields release]; > ... > } > > (The OP called it just 'fields'.) That's not a memory leak -- in the first > part, the MyClass object owns the array it creates (once), and it > relinquishes ownership in its 'dealloc' (once). There can only be a leak for > one of 3 reasons: > > 1. Some other piece of code assigns a new value to 'myFields' without > releasing the old value.
That is the only part of my code that adds values to the field. > > 2. Some other piece of code retains 'myFields', but never releases it. I return the values as keys for an NSDictionary that is the database row. > > 3. The MyClass object is itself leaked, so its dealloc is never called. I shall try and find out if that is happening, but this was the heaviest hit in Instruments. Is there any easy way to find out if this is happening? M_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com