开发者

ERROR: Memory Leak, data formatters temporarily unavailable

开发者 https://www.devze.com 2022-12-20 02:12 出处:网络
I am developing a quiz app. I take questions from a xml file, parse it and display random questions. These are stored in NSdictionary and NSMutableArray. Also the app plays background music and sound

I am developing a quiz app. I take questions from a xml file, parse it and display random questions. These are stored in NSdictionary and NSMutableArray. Also the app plays background music and sound for clicking of buttons(AVAudioPlayer). and vibration( AudioServicesPlaySystemSound(kSystemSoundID_Vibrate))

In one particular function if i try to release the temp variables that I use(I.E NSDictionary and NSMutableArray) the app crashes wen i reach that function for the second time. Hence if i don release these, it works fine but eventually crashes with a "EXC_BAD_ACCESS" ERROR. It does not point out to any line or function.

When i used the tool "LEAKS", it showed i was having around 7000 leaks. I don understand how to use that tool but I am sure that i am not creating so many variables, jus a few and even those I release.

And just once i got the ERROR " data formatters temporarily unavailable".

Any Idea what i am doing wrong?? F1 :)

PS: my code is all simple stuff, plus i donno what the problem is hence i donno what code to post here? Also i would like to know if i create a NSString* in a function for temp use should i release it at the end of the function?(i do release it) EDIT:

    -(void) loadQuestion
    { 
    strCorrectAnswer = @"";
    int intQ开发者_StackOverflow社区uestionNo;
    NSString *strQuestionNo = [[NSString alloc] init];

    // get random question out  the xml file  
NSDictionary *dctQue = [dctQuestions  objectForKey:strQuestionNo];
// blah blah

    // jumble the answers to   be displaed


NSMutableArray *answerJumble = [[NSMutableArray alloc] init];
NSMutableArray *answers =[NSMutableArray arrayWithObjects:[dctQue objectForKey:@"WrongAnswer1"],[dctQue objectForKey:@"WrongAnswer2"],[dctQue objectForKey:@"WrongAnswer3"],[dctQue objectForKey:@"CorrectAnswer"],nil];

 // blah blah

  /*
[strQuestionNo release];
[answers release];
[answerJumble release]; */  

}


You should read something about memory management in Cocoa. See the Mac Developer Center or the tutorial at Cocoa Dev Central. Memory management on iPhone is not hard, it’s a pity to code by trial and error.


well after a bit of digging, the problem was wen the sound file had to be replayed. If i press a button and before the sound file finishes playing if i press again, the sound file was being played just once. Resulting in a memory leak of 3000.

IF i did this twice the app wud crash after a leak of 6425. Hence the ERROR-"data formatters currently not available".(i guess)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号