2014-07-23 3 views
0

Cordova를 사용하여 하이브리드 앱을 개발 중이며,이 앱은 iPad를 제외한 모든 기기에서 훌륭하게 작동합니다. 이 앱은지도 중심적입니다. 즉, 전체보기가지도 상자지도에 표시됩니다. Xcode가 메모리 경고를 조금씩 확대하여 사용자가 확대하거나 축소 할 때이 작업을 몇 번 수행하면 응용 프로그램이 중단됩니다. 나는 잠시 동안 문제를 해결하기 위해 보인다 "메모리 경고를 받았 는가"방법에Cordova/PhoneGapp App 메모리 문제

[[NSURLCache sharedURLCache] removeAllCachedResponses]; 

를 사용했지만, 개발은 계속되고 같은 문제는 다시 느끼게했다.

사람이 다른 본 사람 이 문제?

+0

코르도바 버전 :

다음은 샘플 초기화입니까? 지도 정보 (공급 업체/버전, 플러그인/SDK 또는 원격 JS)? – gro

+0

Cordova 3.5, Mapbox는 Remote JS 파일과 함께 사용 된 제품입니다. – Nathan

+0

초기 캐시 크기 (mem, disk)는 무엇입니까? – gro

답변

0

어떤 도움이되는지 확인할 수 있습니다. AppDelegate.m 초기화 방법, 추가에

... 캐시 크기를 설정 한 후

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { 
    cacheSizeMemory *= 2; (or 1.5, etc. ... test to see what works best) 
    cacheSizeDisk *= 2; (or 1.5, etc. ... test to see what works best) 
} 

.

UPDATE :

- (id)init 
{ 
    NSHTTPCookieStorage* cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 
    [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; 

    int cacheSizeMemory = 8 * 1024 * 1024; // 8MB 
    int cacheSizeDisk = 32 * 1024 * 1024; // 32MB 

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { 
     cacheSizeMemory *= 2; 
     cacheSizeDisk *= 2; 
    } 

#if __has_feature(objc_arc) 
    NSURLCache* sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"]; 
#else 
    NSURLCache* sharedCache = [[[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"] autorelease]; 
#endif 
    [NSURLCache setSharedURLCache:sharedCache]; 

    self = [super init]; 
    return self; 
} 
+0

이 방법으로 정확히 무엇을 설정하고 있는지 명확히 할 수 있습니까? – Nathan

+0

sharedURLCache의 크기를 조정하십시오. appDelegate에서 정의한다고 가정합니다. 그들이 3.5에서 그것을 옮겼는지 확실치 않지만, 초기 3.2에서부터 초기에 설정되어 있습니다. – gro

+0

이것을 사용하여 자신의 캐시를 만드는 경우 [[NSURLCache sharedCache] removeAllCachedResponses];를 사용해야합니다. "메모리 경고를 받았습니다"메서드 – gro