How to find the leaky faucet that loads into Malloc 32kb

Posted by Rob on Stack Overflow See other posts from Stack Overflow or by Rob
Published on 2010-04-14T02:31:50Z Indexed on 2010/04/14 2:43 UTC
Read the original article Hit count: 374

I have been messing around with Leaks trying to find which function is not being deallocated (I am still new to this) and could really use some experienced insight.

I have this bit of code that seems to be the culprit. Every time I press the button that calls this code, 32kb of memory is additionally allocated to memory and when the button is released that memory does not get deallocated.

What I found was that everytime that AVAudioPlayer is called to play an m4a file, the final function to parse the m4a file is MP4BoxParser::Initialize() and this in turn allocates 32kb of memory through Cached_DataSource::ReadBytes

My question is, how do I go about deallocating that after it is finished so that it doesn't keep allocating 32kb every time the button is pressed?

Any help you could provide is greatly appreciated!

- (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];
}

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone-sdk