• 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: My bug or Apple's?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: My bug or Apple's?


  • Subject: Re: My bug or Apple's?
  • From: "John C. Randolph" <email@hidden>
  • Date: Fri, 19 Nov 2004 15:18:03 -0800


On Nov 19, 2004, at 3:04 PM, John Stiles wrote:



Well, as a matter of course, I try to release everything I allocate. At my work, our allocator code will complain about a memory leak if I don't.

In this particular case, TSHashTables destroy each of their elements when they are destroyed, because that's how they were designed. Usually it's helpful. :)

If I just wanted to leak the images, I could make my Image class' destructor do nothing, but that seems like an error to me. Yes, in this particular instance we're quitting anyway, so we don't HAVE to free. But should I really need to make two separate types of Image objects--one that frees itself on destruction, and one that doesn't--just because of this bug? It doesn't seem logical to me.

Well, freeing individual objects when quitting an app serves no purpose, and just makes your app take longer to exit. The problem you're hitting here is that you're using Cocoa objects after the framework has finished its
normal shutdown procedure: that's why there's no autorelease pool in place.


I'd say your best bet is to set a global "isTerminating" flag when the user quits, and have your destructors check that flag and do nothing if it's set.

-jcr



John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html


_______________________________________________ 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: My bug or Apple's?
      • From: John Stiles <email@hidden>
References: 
 >My bug or Apple's? (From: John Stiles <email@hidden>)
 >Re: My bug or Apple's? (From: "John C. Randolph" <email@hidden>)
 >Re: My bug or Apple's? (From: John Stiles <email@hidden>)

  • Prev by Date: Re: Fastest way to push strings to the screen in an NSView?
  • Next by Date: NSSegmentedControl as toolbar item of a textured window
  • Previous by thread: Re: My bug or Apple's?
  • Next by thread: Re: My bug or Apple's?
  • Index(es):
    • Date
    • Thread