问题描述
我正在开发测验应用程序.我从xml文件中获取问题,对其进行解析并显示随机问题.这些存储在NSdictionary和NSMutableArray中.该应用程序还播放背景音乐和声音以单击按钮(AVAudioPlayer).和振动(AudioServicesPlaySystemSound(kSystemSoundID_Vibrate))
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))
在一个特定的函数中,如果我尝试释放我使用的临时变量(即NSDictionary和NSMutableArray),则应用崩溃,因为我第二次到达该函数.因此,如果我不发布这些文件,则可以正常工作,但最终会因"EXC_BAD_ACCESS"错误而崩溃.它不指向任何行或函数.
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.
当我使用工具"LEAKS"时,表明我有大约7000次泄漏.我不知道如何使用该工具,但是我可以确定我创建的变量不是很多,只是有些甚至是我发布的那些变量.
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".
知道我在做什么错吗? F1:)
Any Idea what i am doing wrong?? F1 :)
PS:我的代码都是简单的东西,再加上我不知道出现什么问题,因此我不知道要在此处发布什么代码?我也想知道我是否在临时使用的函数中创建NSString *,是否应该在函数末尾将其释放?(我确实将其释放)
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)
-(void) loadQuestion
{
strCorrectAnswer = @"";
int intQuestionNo;
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]; */
}
推荐答案
在进行了一些挖掘之后,问题在于必须重播声音文件.如果我按一个按钮,并且再按一次,则在声音文件播放完毕之前,声音文件只被播放了一次.导致内存泄漏为3000.
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.
如果两次泄漏6425之后,我两次使应用程序崩溃,则发生错误.因此,出现错误-当前不可用的数据格式化程序".(我想)
IF i did this twice the app wud crash after a leak of 6425. Hence the ERROR-"data formatters currently not available".(i guess)
这篇关于错误:内存泄漏,数据格式化程序暂时不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!