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

PDFOutline memory management


  • Subject: PDFOutline memory management
  • From: "Adam R. Maxwell" <email@hidden>
  • Date: Mon, 16 Apr 2007 20:39:17 -0700

I was checking over some code for memory leaks with MallocDebug, and discovered an NSOutlineView datasource method that retains an object from a PDFOutline instance variable before returning it, but never releases it. Removing the retains causes a crash, and I notice that Apple's sample code

http://developer.apple.com/samplecode/PDFKitLinker2/listing11.html

has a similar implementation (in fact, I think ours was originally copied from it). Note the retains which are never balanced out AFAICT. I've thought of just sticking each child in a set before it's returned, then just releasing the set in -dealloc, but I'd like to know if I'm overlooking something obvious.

- (id) outlineView: (NSOutlineView *) outlineView child: (int) index ofItem: (id) item
{
if (item == NULL) {
if ((_outline) && ([[_pdfView document] isLocked] == NO))
return [[_outline childAtIndex: index] retain];
else
return NULL;
}
else
return [[(PDFOutline *)item childAtIndex: index] retain];
}


thanks,
Adam
_______________________________________________

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: PDFOutline memory management
      • From: John Calhoun <email@hidden>
  • Prev by Date: Including Private Frameworks
  • Next by Date: Re: Getting ColorSync profile path
  • Previous by thread: Re: Including Private Frameworks
  • Next by thread: Re: PDFOutline memory management
  • Index(es):
    • Date
    • Thread