• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTreeController and object retain counts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTreeController and object retain counts


  • Subject: Re: NSTreeController and object retain counts
  • From: "Mads Paulin" <email@hidden>
  • Date: Mon, 9 Nov 2009 12:31:47 +0100 (CET)
  • Importance: Normal

Hi,

Yes my Document class releases the array in its dealloc method and all Node
objects in the array are properly dealloc'ed when deallocing the document.

However, I think the problem is unrelated to the retaining of the array
member of the document class but rather to the retaining of elements added
to the array via NSTreeControllers add:sender and remove:sender class.

Adding a node object through this method creates a node object in the
document array member with a retain count of 2. The remove:sender method
correctly removes the object from the document's array but only decrements
the node object's retain count to 1 - meaning that the objects are never
dealloc. As I see it, this is a memory leak in NSTreeController as all "my"
external references to the Node objects are lost.

Thanks,
Mads



> Mads Paulin wrote:
>
>> #import <Cocoa/Cocoa.h>
>>
>> @interface MyDocument : NSDocument
>> {
>> 	NSMutableArray *array;
>> }
>>
>> @property (readonly) NSMutableArray* array;
>>
>> @end
>>
>> All I changed in the doc impl is
>> @synthesize array
>> and
>> array =[ [NSMutableArray]alloc init]; in the init method.
>
>
> Does your MyDocument implementation ever release array?  If not, then
> what happens to the NSMutableArray and what it contains when
> MyDocument is dealloc'ed?  I don't think @synthesize will synthesize
> any cleanup for you.
>
>    -- GG
> _______________________________________________
>
> 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
>

_______________________________________________

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

  • Follow-Ups:
    • Re: NSTreeController and object retain counts
      • From: Andy Lee <email@hidden>
    • Re: NSTreeController and object retain counts
      • From: Graham Cox <email@hidden>
References: 
 >Re: NSTreeController and object retain counts (From: Greg Guerin <email@hidden>)

  • Prev by Date: Re: beginner question, NSNumber, NSDecimalAsNumber
  • Next by Date: Re: NSTreeController and object retain counts
  • Previous by thread: Re: NSTreeController and object retain counts
  • Next by thread: Re: NSTreeController and object retain counts
  • Index(es):
    • Date
    • Thread