如果我做以下的事情,这样会令内存泄漏?

SomeClass* tmp;
NSDate* thetmpdate;

tmp = [[[SomeClass alloc] init] autorelease];
thetmpdate = [NSDate date];
// Do something long with tmp and date

tmp = [[[SomeClass alloc] init] autorelease];
thetmpdate = [NSDate date];
// Do something long with tmp and date

tmp = [[[SomeClass alloc] init] autorelease];
thetmpdate = [NSDate date];
// Do something long with tmp and date
有帮助吗?

解决方案

没有,有一个在您发布的代码没有泄漏。 当自动释放池冲洗所有对象将被自动释放,不管可变保持它们的指针被改变或没有。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top