• 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: Leaks with Core-Data while fetching data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Leaks with Core-Data while fetching data


  • Subject: Re: Leaks with Core-Data while fetching data
  • From: Chris Hanson <email@hidden>
  • Date: Mon, 7 May 2007 11:33:02 -0700

On May 7, 2007, at 10:08 AM, Hell's KItchen Hell's KItchen wrote:

I've used MallocDebug in order to see leaks and memory usage. I've
found that in my function:

Do you actually release the NSFetchRequest represented by your "request" ivar anywhere?


Are you checking for leaks *after* the fetch request is released, at a point where you *know* that it will be deallocated? The code that you have shown doesn't have any leaks.

It does give back bogus data, though, because you didn't follow my recommendation in introducing an NSAutoreleasePool. I specifically said to wrap the code that *calls* this in a periodically-released NSAutoreleasePool to prevent your high-water mark from growing too much. Not to put the body of this method in an NSAutoreleasePool! As you can see just by inspecting your code, you get an array from a fetch, get the last object from that array, *release the pool that object may be in* and then hand it back. That means you're handing back a zombie object.

Please try applying the recommendations, and pick a correct point to actually perform your leak checking. (For example, after launching your app, opening a document, and then closing it, to ensure that all of the objects associated with the document have been released.) Taking things step by step will help a lot.

  -- Chris

PS - Also, please consider applying our other performance recommendations, particularly about not performing a fetch for every single article downloaded at the time it's downloaded. You're intermixing a whole lot of work that way, work that can probably be effectively batched.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Leaks with Core-Data while fetching data
      • From: mmalc crawford <email@hidden>
References: 
 >Leaks with Core-Data while fetching data (From: "Hell's KItchen Hell's KItchen" <email@hidden>)
 >Re: Leaks with Core-Data while fetching data (From: Chris Hanson <email@hidden>)
 >Leaks with Core-Data while fetching data (From: "Hell's KItchen Hell's KItchen" <email@hidden>)
 >Re: Leaks with Core-Data while fetching data (From: Chris Hanson <email@hidden>)
 >Re: Leaks with Core-Data while fetching data (From: "Hell's KItchen Hell's KItchen" <email@hidden>)

  • Prev by Date: Re: How do you convert a byte array to a int or long, NSNumber has not byte init method.
  • Next by Date: Java drawing into a NSView
  • Previous by thread: Re: Leaks with Core-Data while fetching data
  • Next by thread: Re: Leaks with Core-Data while fetching data
  • Index(es):
    • Date
    • Thread