我们在iOS中有一个Phonegap应用程序,它具有非常高的数据,可从服务器下载。使用的Phonegap版本是2.9.0。在某一点上,应用程序工作正常。但随着数据量的增加,应用程序崩溃会给出内存警告错误。我们使用HTML和Javascript将数据与元素绑定在一起。但我们还没有找到崩溃的原因。
我们在AppDelegate的init方法中有以下代码
- (id)init
{
/** If you need to do any extra app-specific initialization, you can do it here
* -jm
**/
NSHTTPCookieStorage* cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
int cacheSizeMemory = 8 * 1024 * 1024; // 8MB
int cacheSizeDisk = 32 * 1024 * 1024; // 32MB
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad || [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
cacheSizeMemory *= 20;
cacheSizeDisk *= 20;
}
#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;
}
我们还在applicationDidReceiveMemoryWarning
中添加了以下代码- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application
{
[[NSURLCache sharedURLCache] removeAllCachedResponses];
}
上述事情还没有帮到我们。非常感谢任何形式的帮助和指导。