문제

If I do the following thing, will this make memory leaks ?

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
도움이 되었습니까?

해결책

No, there's no leak in the code you posted. All objects will be autoreleased when the autorelease pool is flushed, no matter if the variable holding their pointers is changed or not.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top