2011-07-08 13 views
1

リークツールで報告された問題の原因を特定できないようです。問題のコードはここにあり、問題の行はマークされています。何か案は?どのオブジェクトがリークであるかを正確に調べる方法はありますか?問題コアのメモリリークデータコード

NSArray *getAllCoreData(NSString *entityName, NSString *orderedBy, BOOL ascending, BOOL shallow) 
{ 
// Get the managed object context 
NSManagedObjectContext *moc = [[AppController sharedAppController] managedObjectContext]; 

// Create a fetch request that fetches from 'entityName' 
NSFetchRequest *fetch = [[NSFetchRequest alloc] init]; 
NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:moc]; 
[fetch setEntity:entity]; 

// Try to do the fetch 
NSError *error; 
NSArray *result = [moc executeFetchRequest:fetch error:&error]; <----- Problem line 

[fetch release]; 

// Did the fetch fail? 
if (!result) 
{ 
    // Display an alert view 
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Fetch Failed" 
                 message:[error localizedDescription] 
                 delegate:nil 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil]; 

    [alertView autorelease]; 
    [alertView show]; 
    return nil; 
} 

// Return the array of instances of NSManagedObject 
return result; 
} 

すべてのヘルプは非常に理解されるであろう、 ジェイソン

+0

こんにちはjasonさん、私も同様の問題に直面していますので、この問題の解決策を投稿してください。 – ujjawal

答えて

1

リークは、メモリが、あなたがこれ以上の言及がなかった後の周りに維持した割り当てられたあなたを語っています。

結果を返すと、それ以外のものが長すぎて、完了してから解放されません。

+0

あなたは絶対に正しいです!どうやらトンネルビジョンが始まり、私はこのルーチンを見ることができなかったようです。私の正気はあなたに感謝します。 – Jason

1

は、それは本当のリークではないかもしれない

NSError *error = nil; 

NSError *error; 

を変更してみてください。可能性として、NSError *errorにはちょっと残ったポインタがあるので、ツールのリークのように見えます。

+0

それは問題ではありませんでしたが、私もそれをきれいにしました。ありがとう。 – Jason

関連する問題