-- iOS (iPhone)
iphone에서 메모리 문제로 URL로 데이터를 가끔씩 못 가져올 때
어린왕자악꿍
2013. 1. 4. 13:29
iPhone4에서 제대로 동작하던 소스가 iPhone5에서 가끔씩 메모리 오류를 발생시킨다.
(IPhone4, IPhone5 모두에서 발생하는 문제로 버전보다는 범용적인 메모리 문제 같음)
특히 메모리나 캐시 문제 등에 의해 아래와 같은 메시지가 나온다.
ADDRESPONSE - ADDING TO MEMORY ONLY
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
int cacheSizeMemory = 4 * 1024 * 1024;
int cacheSizeDisk= 32 * 1024 * 1024;
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory
diskCapacity:cacheSizeDisk
diskPath:@"nsurlcache"];
[NSURLCache setSharedURLCache:sharedCache];
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
[[NSURLCache sharedURLCache] removeAllCachedResponses];
}
현재까지는 제대로 동작하고 에러발생이 없으나, 혹시 추후에라도 문제가 다시 발견되면 수정하도록 하겠다.
참고 : http://stackoverflow.com/questions/12547490/log-messages-i-didnt-asked-for-in-xcode-4-5-with-ios-6-0