이 코드의 문제점은 while 루프가 실행될 때 메모리 사용이 지속적으로 증가한다는 것입니다. 이 코드는 while 루프에서 메모리를 늘리는 이유가 무엇인지 알고 싶습니다. 메모리를 먹고있는 개체가 여기에 있습니다. 루프에서 메모리가 증가하지 않도록하려면 어떻게해야합니까?while 루프 메모리 문제
당신이 거기있는 일부 비효율적 인 코드가NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSNumber *totalTime = [[self nowPlayingItem] valueForProperty:MPMediaItemPropertyPlaybackDuration];
while (self.currentPlaybackTime < [totalTime floatValue])
{
NSNumber *currentTime = [[NSNumber alloc] initWithFloat:self.currentPlaybackTime];
if([[NSThread currentThread] isCancelled])
{
[NSThread exit];
[newThread release];
}
else if([totalTime intValue] - [currentTime intValue] == 1.0)
{
if(currentTime)
[currentTime release];
break;
}
[currentTime release];
}
[pool release]
[풀 드레인]이고; 할당 계기를 사용하여 문제가 발생하면 찾으십시오. – 0xDE4E15B
내가 언급 한 것처럼 루프가 실행 중일 때 메모리가 증가합니다. Allocations 장비에서 얻을 수있는 것이 있습니까? – Dhawal
작년의 WWDC 비디오를 보면 잠시 동안 자동 회수 풀이 놓이는 것을 볼 수 있습니다. 이렇게하면주기 당 모든 자동 회수 객체가 해제되므로 메모리 유출이 줄어 듭니다. – rckoenes