OpenGL 앱에서 didreceiveMemoryWarning에 응답하는 방법
-
13-09-2019 - |
문제
내 앱은 많은 메모리를 사용합니다. 일반적으로 잘 작동하지만 잠시 동안 다시 시작되지 않은로드 된 장치에서는 악명 높은 낮은 메모리 오류로 인해 제기됩니다.
응답하고 싶습니다 didReceiveMemoryWarning
그리고 내 캐시 중 일부를 풀어주십시오.
그러나 내 앱이 OpenGl ES 템플릿을 기반으로하고 View Controller가 없다는 문제가 있습니다. Glview에 대한 참조를 보유한 앱 대의원이 있습니다.
내가 랩하기 위해 무엇을 할 수 있습니까? didReceiveMemoryWarning
응답 할 수 있도록 메시지?
해결책
이것은 또한 귀하의 내에서 사용할 수 있습니다 신청서 대의원.
-(void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
NSLog(@"Received memory warning!");
}
다른 팁
또한 원하는 클래스에서 관찰자로 메소드를 추가 할 수도 있습니다. UIApplicationDidReceiveMemoryWarningNotification
공고. 코드는 다음과 같이 좋아할 수 있습니다.
- (void) cleanMemory: (NSNotification*) notification {
// Save memory!
}
- (id) init { // Or any other function called early on.
// other init code
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(cleanMemory:)
name:UIApplicationDidReceiveMemoryWarningNotification
object:nil];
return self;
}
제휴하지 않습니다 StackOverflow