私は、どの関数が割り当て解除されていないかを見つけようとしてLeaksをいじり回しており(私はまだこれに慣れていません)、経験豊富な洞察を実際に使用できます。
私は犯人のように見えるこのコードを持っています。このコードを呼び出すボタンを押すたびに、32kbのメモリがメモリに追加で割り当てられ、ボタンを離してもそのメモリの割り当ては解除されません。
私が見つけたのはAVAudioPlayer
、m4aファイルを再生するために呼び出されるたびに、m4aファイルを解析する最後の関数はでMP4BoxParser::Initialize()
あり、これにより32kbのメモリが割り当てられます。Cached_DataSource::ReadBytes
私の質問は、ボタンが押されるたびに32kbが割り当てられないように、終了後に割り当てを解除するにはどうすればよいですか?
あなたが提供できるどんな助けも大歓迎です!
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
//stop playing
theAudio.stop;
// cancel any pending handleSingleTap messages
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(handleSingleTap) object:nil];
UITouch* touch = [[event allTouches] anyObject];
NSString* filename = [g_AppsList objectAtIndex: [touch view].tag];
NSString *path = [[NSBundle mainBundle] pathForResource: filename ofType:@"m4a"];
theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio prepareToPlay];
[theAudio setNumberOfLoops:-1];
[theAudio setVolume: g_Volume];
[theAudio play];
}