Re: Newbie question - Leak in NSDictionary
Re: Newbie question - Leak in NSDictionary
- Subject: Re: Newbie question - Leak in NSDictionary
- From: Thomas Lachand-Robert <email@hidden>
- Date: Sun, 16 Mar 2003 16:39:55 +0100
Le dimanche, 16 mars 2003, ` 14:40 Europe/Paris, Andres Ramirez a icrit
:
Hello. I seem to be missing an important concept, since this code is
leaking. The initial parts of the messages I get are pasted after
the code. As far as I can tell, the leak happens due to the
NSDictionary line.
fileAttributesAtPath returns an autoreleased dictionary: this implies
that you need to have an autorelease pool in place. This is done for
you automatically in the main thread of any AppKit based application,
but if you are building a Foundation tool or using a new thread, you
need to create a pool:
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
// now you can use fileAttributesAtPath, etc.
[pool release]; // don't forget to release the pool at the end
Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.
_______________________________________________
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.