如果我执行以下操作,是否会导致内存泄漏?
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
答案 0 :(得分:6)
不,您发布的代码没有泄漏。 刷新自动释放池时,所有对象都将自动释放,无论保持其指针的变量是否发生变化。