• 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: Weird retain Issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird retain Issue


  • Subject: Re: Weird retain Issue
  • From: Karl Goiser <email@hidden>
  • Date: Wed, 25 Feb 2004 11:08:07 +1100

On 25/02/2004, at 10:13 AM, Shawn Erickson wrote:


On Feb 24, 2004, at 2:44 PM, Karl Goiser wrote:

Hello,

I wonder if anybody can explain this for me?

One object needs a reference to another object, so the first object's init method contains a line like:

instanceVariable = [parameter retain];

Fairly standard stuff. Except that running ObjectAlloc shows that the object being passed in doesn't ever get dealloc'ed. But if I change the above line to (and make no other changes to the code):

instanceVariable = parameter;
[instanceVariable retain];

The object does get dealloc'ed.

I can almost 100% state that the above change is not the source of your dealloc issue but something else in your code. You may have stumbled across partially rebuilt project code that lead you to believe this change resulted in a change of application behavior.

Of course if the object referenced by parameter has a broken retain method, one that doesn't return self, then that is the source of your issue (since the assumed release messages gets sent to the incorrect object) but we cannot tell that without knowing more about the code, what parameter could be, etc.

All we know is that you are retaining something and we have to assume you are releasing it some place...


Hi Shawn,

Thanks for replying.

I feel the same way about it as you and would really like to locate the source of the issue.


Some more detail:
There are no overrides of retain, release etc.
I have tried rebuilding the project including removing the 'Build' directory.

The first object is just used in an array as a place-holder for information about the second, so there is an NSMutableArray 'Items' of 'Item' (the first object).

Item's relevant methods are:

- (id) initWithBog: (Bog *) bogParam
{
self = [self init];
if (self) {
bog = bogParam;
[bog retain];
}
return self;
}


- (void)dealloc
{
[bog release];
[super dealloc];
}


The Items array is properly dealloc'ed.
The Item objects are properly dealloc'ed.
Bogs aren't unless the retain method is put in a separate line.


Regards,

Karl
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Weird retain Issue (From: Karl Goiser <email@hidden>)
 >Re: Weird retain Issue (From: Shawn Erickson <email@hidden>)

  • Prev by Date: Re: Tooltip for cell or column of NSTableView?
  • Next by Date: Re: Tooltip for cell or column of NSTableView?
  • Previous by thread: Re: Weird retain Issue
  • Next by thread: Tooltip for cell or column of NSTableView?
  • Index(es):
    • Date
    • Thread