私は、リソースをダウンロードして後でオフラインで使用できるようにディスクに書き込むアプリに取り組んでいます。これは常にカスタムコンテンツです。現在、約4000のJPGがあるコンテンツを処理しています。ユーザーはiPadへのコンテンツのダウンロードを初期化し、UIにプログレスバーがあるため、ユーザーは基本的に完了するまで待機します。問題は、約180〜190 MBのメモリが割り当てられ、クラッシュすることです。
Instrumentsで見たのは、CFData(ストア)が主な原因であり、CFData(ストア)がNSURLConnection要求のキャッシュであるということです。
私はもう試した:
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
[sharedCache release];
と
[[NSURLCache sharedURLCache] removeAllCachedResponses];
キャッシュポリシーを設定するだけでなく、改善はありません。
参考までに、これは私の投稿リクエストがどのように見えるかです:
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setCachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
NSString *contentType = [NSString stringWithFormat:@"text/xml"];
[request addValue:contentType forHTTPHeaderField: @"Content-Type"];
NSMutableData *postBody = [NSMutableData data];
[postBody appendData:[xmlMessage dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postBody];
//get response
NSHTTPURLResponse* urlResponse = nil;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&httpError];
どんな助けでも大きな拍手で満たされるでしょう。