cocoa memory leak of NSCFString but I have no alloc or retain
Instrument tells me
NSCFString 16Bytes Foundation -[NSPlaceholderString
My code is like:
BOOL rslt = [self sendLogInfo:[NSString stringWithFormat:@"%@", [nameField text]] andPasword:[NSString stringWithFormat:@"%@",[passField text]]];
But without an开发者_Python百科y alloc method. Could anyone please tell me what is wrong with the code?
There are two possibilities:
sendLogInfo:
, or some other code that you didn't show, retains the string, either directly (by sending it aretain
message) or indirectly (by setting it as the value of astrong
/retain
property).- That code is not the code that produces the string shown in Instruments.
If you hover the mouse over the address (0xblahblah
) in the string's row in Instruments, you'll see a button that looks like this: ➲ If you click on that, it will take you to the History for that address, which will list the allocation and every retain, autorelease, and release of that string. You can then examine each event's call stack to see what caused it.
One of those is the cause of the leak: Either an undue retain, or a retain (or the allocation) that needs to be balanced by a release but isn't.
精彩评论