[Oops, I realized I didn't Reply-All and include the list in my first answer.]

On Oct 1, 2008, at 1:45 PM, Christopher J Kemsley wrote:

I do better than that - on the dealloc call, my code explicitly deallocates it.

Meaning, I assume, in this containing class's -dealloc, you call [editedRowName dealloc]? I don't think you want to do that; I don't think you're supposed to call -dealloc yourself, but rather -release, and let the system call -dealloc if necessary.

On Oct 1, 2008, at 12:44 PM, Randall Meadows wrote:
On Oct 1, 2008, at 1:34 PM, Christopher J Kemsley wrote:
I'm writing a program that, in one table view, has the following code:

id receivedName = [theDatabase itemAtIndex:editedRow] ;
editedRowName = [receivedName mutableCopy] ;
[receivedName release];

where "editedRowName" is defined as an NSMutableString.

[theDatabase itemAtIndex:editedRow]

Asks my database to return item "editedRow." The object at that index is an NSString. For this function, the database would return

[theStringHere retain]

My code needs a mutable version of this string, so I make a mutableCopy of it and release the old one, as to prevent a memory leak.

OK, good...

However, when I do a "Run with performance tool: Leaks", it tells me that, ever time this part of the code runs, it leaks a "GeneralBlock-32" with the following information:

Category: CFString (store)
Event Type: Malloc
Responsible Library: Foundation
Responsible Caller: -[NSCFString mutableCopyWithZone:]

Does anybody know where this leak is coming from?

Do you [auto]release "editedRowName", the mutable instance? By using the -mutableCopy: method, you are responsible for releasing the result explicitly.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to