• 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: Debugging suggestion for memory leak?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debugging suggestion for memory leak?


  • Subject: Re: Debugging suggestion for memory leak?
  • From: Shawn Erickson <email@hidden>
  • Date: Sun, 21 Apr 2002 10:02:22 -0700

On Sunday, April 21, 2002, at 09:23 AM, Rich Long wrote:

Hi,

I'm a Cocoa newbie and having a bit of a thorny problem. I have a lengthy operation that I run in a thread, and as part of that I put up a progress dialog. The trick is that the progress dialog is implemented as a "stack" on a single panel, so as other parts of the code (within the thread) invoke a progress dialog, the panel state (labels, etc.) is remembered and the panel reused. As each instance of the stacked panel is unwound, the previous state of the panel is restored, and the last instance releases the panel. I do create and release an autorelease pool within the thread.

This is working OK, but I get this message consistently:

*** _NSAutoreleaseNoPool(): Object 0x220310 of class NSCalibratedRGBColor autoreleased with no pool in place - just leaking

You need to create an autorelease pool to catch autoreleased objects (also need to release it at some point to free the contained autoreleased objects). Every NSThread maintains its own stack of autorelease pools. I believe by default the stack is empty (the main thread gets an autorelease pool created for it, usually in main or in the event loop of your application).

See the autorelease pools link on the following page (upper left table):
http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/ProgrammingTopics/
MemoryMgmt/index.html

Also see the NSAutoreleasePool docs: http://developer.apple.com/techpubs/macosx/Cocoa/Reference/Foundation/ObjC_classic/
Classes/NSAutoreleasePool.html

Relevant snippet....

"NSAutoreleasePools are automatically created and destroyed in applications based on the Application Kit, so your code normally does not have to worry about them. The Application Kit creates a pool at the beginning of the event loop and releases it at the end. You have to create your own autorelease pool if you do not use the Application Kit or detach a thread that uses Cocoa.
...
When a thread terminates, it automatically releases all of the autorelease pools associated with itself."

-Shawn
_______________________________________________
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: 
 >Debugging suggestion for memory leak? (From: Rich Long <email@hidden>)

  • Prev by Date: Re: releasing a NSArray
  • Next by Date: Compile times.
  • Previous by thread: Debugging suggestion for memory leak?
  • Next by thread: Re: releasing a NSArray
  • Index(es):
    • Date
    • Thread