• 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
Debugging complex autorelease/release/retain issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Debugging complex autorelease/release/retain issue


  • Subject: Debugging complex autorelease/release/retain issue
  • From: Skip Haughay <email@hidden>
  • Date: Sun, 19 Nov 2006 17:12:59 -0800

Hey all:

I have a leak in my code I am attempting to chase down, and in doing so, I need some clarification of the behavior of autorelease pool objects.  In order to debug my class memory cycle, I overrode the following:

+ (id) alloc   // Added NSLog to indicate object allocation to console
- (void) dealloc  // Added NSLog to indicate object deallocation to console
- (id)retain   // Added NSLog to indicate retain call, plus show the retainCount to console
- (void)release // Added NSLog to indicate release call, plus show the resulting retainCount

I have an object that is alloc'ed, and then autoreleased.  The class which requested the new object then retains it.  There is an indeterminate sequence of retains and releases that occurs as this object is shared among several other objects.

At the end of it all, the object SHOULD be going away via the autorelease.  But it doesn't seem that the dealloc method is EVER invoked.  Indeed, after the last release, the retainCount is still 1.

But what I am curious about is, when the autorelease pool is dumped, is the retainCount of the object decremented at THAT point, or should it be zero after the last release, and the release of the autorelease pool will clean it out if it is zero?  Furthermore, when an object is dumped from disposing of the autorelease pool, the dealloc for that object SHOULD be called, right?  I am setting a breakpoint therein, and it isn't happening.

Thanks,


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Debugging complex autorelease/release/retain issue
      • From: Scott Ribe <email@hidden>
    • Re: Debugging complex autorelease/release/retain issue
      • From: "Philip Q" <email@hidden>
  • Prev by Date: Re: window shadow and setAlphaValue bug?
  • Next by Date: Re: Debugging complex autorelease/release/retain issue
  • Previous by thread: Overriding bind:toObject:withKeyPath:options:
  • Next by thread: Re: Debugging complex autorelease/release/retain issue
  • Index(es):
    • Date
    • Thread