【发布时间】:2011-08-09 15:10:21
【问题描述】:
字符串一的位。使用以下代码(为示例简化)时,我不断收到有关死存储和潜在泄漏的通知:
int x = 0;
NSString *aString = [NSString alloc]init]; <-- value store to 'aString' during its initialization is never read
if(x == 0)
{
aString = @"This is a string set by x being 0";
} else
{
aString = @"This is a string set by x being something else";
}
aTextLabelOutlet.text = aString;
[aString release];
<-- Potential leak of an object allocated online ... and stored into aString
我真的不明白这一点。它被分配一次,然后在使用后释放。它被初始化,然后总是有一些东西放入其中并且总是被读取。
它从未崩溃或实际上导致内存泄漏,所以我有点困惑。
【问题讨论】:
标签: ios xcode memory-leaks