• 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: Fixing a leak in an NSFormatter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fixing a leak in an NSFormatter


  • Subject: Re: Fixing a leak in an NSFormatter
  • From: Darrin Cardani <email@hidden>
  • Date: Wed, 7 Apr 2004 15:39:34 -0500

At 10:26 PM +0200 4/7/04, Stiphane Sudre wrote:
It's a bit surprising it's not crashing a bit later

How is it surprising? Are you implying that I'm double releasing something?

- (NSAttributedString*)attributedStringForObjectValue:(id)anObject
withDefaultAttributes:(NSDictionary*)attributes
{
// Get the non-formatted string
NSString* regularString = [ self stringForObjectValue:anObject ];
...
// Create an attributed string from the non-formatted one,
//but add our attributes
retVal = [ [ NSAttributedString alloc ]
initWithString:regularString attributes:newAttribs ];

// Clean up
[ newAttribs release ];
[ regularString autorelease ];

Why do you want to release regularString? It's already autoreleased.

Why do you say it's already autoreleased? Doesn't that depend on how I created it in -stringForObjectValue: ?

The ending code should be AFAIK:

[ newAttribs release ];

return [retVal autorelease];

When I do that, I get a crash when the next autorelease pool releases its objects.

Darrin
--
Darrin Cardani - email@hidden
President, Buena Software, Inc.
<http://www.buena.com/>
Video, Image and Audio Processing Development
_______________________________________________
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: Fixing a leak in an NSFormatter
      • From: Shawn Erickson <email@hidden>
References: 
 >Re: Fixing a leak in an NSFormatter (From: Stéphane Sudre <email@hidden>)

  • Prev by Date: Finding an disabling particular calls in an application?
  • Next by Date: Re: Re: Drawer Edges Change
  • Previous by thread: Re: Fixing a leak in an NSFormatter
  • Next by thread: Re: Fixing a leak in an NSFormatter
  • Index(es):
    • Date
    • Thread