• 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
I don't understand why this is leaking...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

I don't understand why this is leaking...


  • Subject: I don't understand why this is leaking...
  • From: Cate Tony <email@hidden>
  • Date: Sat, 09 Aug 2008 17:48:42 -0500

This code is leaking:

- (void)saveItemExtensions:(id)sender
{
NSMutableString* itemExtensionsFilePath = [NSMutableString stringWithString:@"~/Library/Preferences/MyApp/extensions.abc"];
NSDictionary* extensions = [NSDictionary dictionaryWithDictionary: [itemDataSource itemExtensions]];


[itemExtensionsFilePath setString:[itemExtensionsFilePath stringByExpandingTildeInPath]];
[[NSArchiver archivedDataWithRootObject:extensions] itemExtensionsFilePath atomically: YES];
}


- (void)encodeWithCoder:(NSCoder *)coder
{
    [coder encodeObject: string1];
    [coder encodeObject: string2];
    [coder encodeObject: string3];
    [coder encodeObject: string4];
    [coder encodeObject: string5];
    [coder encodeObject: string6];
    [coder encodeObject: string7];
    [coder encodeObject: string8];
}
According to MallocDebug, the leak is in the encodeWithCoder method.

Things I've tried:

1 [coder encodeObject: [string1 autorelease]]; Which, of course, caused a crash
2 [coder encodeObject: [string1 copy]]; no diff
3 [coder encodeObject: [[string1 copy] autorelease]]; no diff
4 Drinking beer...


Can anyone explain this to me?

Tony




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: I don't understand why this is leaking...
      • From: Jean-Daniel Dupas <email@hidden>
    • Re: I don't understand why this is leaking...
      • From: Jonathan deWerd <email@hidden>
  • Prev by Date: Re: Does [NSApp setApplicationIconImage] leak memory?
  • Next by Date: compiling a bundle on intel?
  • Previous by thread: Re: Custom URL Handling
  • Next by thread: Re: I don't understand why this is leaking...
  • Index(es):
    • Date
    • Thread