• 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 retainCount
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Debugging retainCount


  • Subject: Debugging retainCount
  • From: The Amazing Llama <email@hidden>
  • Date: Mon, 14 Jul 2003 19:56:46 -0700

I had a memory leak in my program where I was autoreleasing too often (which is the memory leak I always seem to have), and I think I've figured out a simple way to track these things down.

Why couldn't NSObject be enhanced so that every time it gets an -autorelease message, it increments a counter. It then checks this counter against it's retainCount and debugger-breaks if the pending autoreleases are greater than the retains.

I could do this myself with a poseAs: but I don't know how to decrement the counter on getting a release from the autorelease pool. I suppose you could check the stack, but that seems a little hackish.

However, this would make a very nice, very simple addition to the frameworks, but making the NSAutoreleasePool decrement the counter before calling -release.

Unless (as I probably am) I am overlooking something simple that makes all this impossible. Would this work?

Seth A. Roby The Amazing Llama < mail or AIM me at tallama at mac dot com>
"Life is like an exploded clown. It's really funny until you figure out what just happened."
_______________________________________________
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.
  • Follow-Ups:
    • Re: Debugging retainCount
      • From: Brent Gulanowski <email@hidden>
    • Re: Debugging retainCount
      • From: publiclook <email@hidden>
    • Re: Debugging retainCount
      • From: Jeff Harrell <email@hidden>
  • Prev by Date: Re: NSDocument Default Contents
  • Next by Date: Re: disabling font smoothing...
  • Previous by thread: Re: disabling font smoothing...
  • Next by thread: Re: Debugging retainCount
  • Index(es):
    • Date
    • Thread