Re: Does cocoa just leak?
Re: Does cocoa just leak?
- Subject: Re: Does cocoa just leak?
- From: Rosyna <email@hidden>
- Date: Sat, 29 Sep 2001 22:19:29 -0700
Ack, at 9/30/01, Fabrice Truillot said:
>
On Dimanche, septembre 30, 2001, at 06:26 , Rosyna wrote:
>
>
>And why isn't all the strings released when awakeFromNib is over
>
>when an Auto release pool is not explicitly declared?
>
>
http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/ProgrammingTopics/MemoryMgmt/index.html
>
>
Cocoa has some memory management policies you should now.
>
>
"Ideally a body of code should never be concerned with releasing
>
something it didn't create. Cocoa therefore sets this policy: If you
>
create an object (using alloc or allocWithZone:) or copy an object
>
(using copy, copyWithZone:, mutableCopy, or mutableCopyWithZone:),
>
you alone are responsible for releasing it. If you didn't directly
>
create or copy the object, you don't own it and shouldn't release
>
it."
>
>
[[instance URL] path] possibly creates 2 temporary instances (NSURL
>
& NSString ?), autoreleased with the active NSAutoreleasePool.
>
>
>
[[NSFileManager defaultManager] // returns an autoreleased NSFileManager
>
fileExistsAtPath:
>
[[instance URL] // another autoreleased instance (NSURL)
>
path]]; // and now : an autoreleased NSString
>
>
When the active NSAutoreleasePool is released, theses instances will
>
be recycled.
This doesn't seem to be 100% reliable. My main problem is with the
other leaks, not the main loop one. Casual leaks. Example, I leave my
one application open for a few hours, (it's doing nothing) and when I
look again, its eating 20megs ram.
>
Without an active NSAutoreleasePool, the memory will leaks...
>
>
[NSAutoreleasePool showPools]; shows the state of the current
>
NSAutoreleasePools (for the current thread). Try it !
Where is this documented? NSAutoreleasePool.h only defines
+ (void)addObject:(id)anObject;
- (void)addObject:(id)anObject;
--
Sincerely,
Rosyna Keller
Technical Support/Holy Knight/Always needs a hug
Unsanity: Unsane Tools for Insane People