私は前にそのような問題に遭遇したことはありません..そして今、私はこれを処理する方法がわからず、助けを求めています.
ビューコントローラー(exampleViewControllerとしましょう)をナビゲーションコントローラーにプッシュしています。私のexampleViewController on viewdidloadでは、画像を含むimageviewを追加します。dealloc では、このイメージビューをスーパービューから削除してから、保持されているビューを解放します。インスツルメント リーク ツールにはリークは表示されませんが、インスツルメント - 「アクティビティ モニター」を開くと、exampleViewController をプッシュすると実際のメモリが 5 MB 増加し、exampleViewController をポップすると、メモリが 3 だけ減少することがわかります。 MB ..このexampleViewControllerを何度もプッシュアンドポップすると、メモリ警告が表示され、その後アプリが終了します。
他のView Controllerが期待どおりに動作するため、私は間違いなく何か間違っています。問題は、私が何を間違っているのかわからないことです。これを引き起こしている原因を突き止める方法をいくつか提案してください。
私は alloc ツールのようなインストゥルメントでいくつかのツールを試してから、ヒープをマークし、いくつかの同様のものを試しましたが、それは何がリークされるかを示していません:/
前もって感謝します!!
編集:
インストゥルメントでヒープをマークすると、executeFetchRequest: がリークしているように見えます。
+ (Question *)getQuestionWithId:(NSString *)questionId
{ 質問 *resultQuestion = nil;
AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
//geting context from appdelegate
NSManagedObjectContext *context = appDelegate.managedObjectContext;
//form fetch request with predicate
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Question"
inManagedObjectContext:context];
NSPredicate *query = [NSPredicate predicateWithFormat:@"questionId=%@",questionId];
NSPredicate *query1 = [NSPredicate predicateWithFormat:@"type='ke'"];
NSPredicate *predicates = [NSCompoundPredicate andPredicateWithSubpredicates:[NSArray arrayWithObjects:query,query1, nil]];
[fetchRequest setPredicate:predicates];
[fetchRequest setEntity:entity];
NSError *error = nil;
NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
[fetchRequest release];
resultQuestion = [fetchedObjects lastObject];
return resultQuestion;
}