Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-15-2011, 06:36 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 35
Kenenth is on a distinguished road
Default How do I stop an AV Audio memory leak?

in my app, when I test on a device, It crashes. I have tested it with instruments and I have figures out that there is a huge leak every time I call a sound, like the background music track which just escalates with leaked memory. here is my code:

Code:
	[startbutton setHidden:YES];
	troopSpawnTimer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(spawnParatrooper) userInfo:nil repeats:YES];
	lowerParatrooperTimer = [NSTimer scheduledTimerWithTimeInterval:.03 target:self selector:@selector(lowerParatroopers) userInfo:nil repeats:YES];
	bulletTimer = [NSTimer scheduledTimerWithTimeInterval:0.03 target:self selector:@selector(checkCollisionAndMove) userInfo:nil repeats:YES];
	bulletCheckTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(bulletCheck) userInfo:nil repeats:YES];
	
	NSString *path = [[NSBundle mainBundle] pathForResource:@"GloriousMorning" ofType:@"mp3"];
	AVAudioPlayer *theAudioMusic=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
	//float music_Volume = [[NSUserDefaults standardUserDefaults] floatForKey:@"musicVolume"];
	//theAudioMusic.volume = music_Volume;
	[theAudioMusic play];
	[theAudioMusic release];
	[path release];

How can I modify this so that there will be no leaking memory? Thanks!
Kenenth is offline   Reply With Quote
Old 03-15-2011, 07:15 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2009
Location: Doncaster UK
Posts: 120
acegames is on a distinguished road
Default

remove [path release] to see if it fixes the crash first
acegames is offline   Reply With Quote
Reply

Bookmarks

Tags
avaudio, crash, leaking, memory

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 364
12 members and 352 guests
Absentia, akphyo, apatsufas, BinHex, blueorb, fredidf, iAppDeveloper, iGamesDev, Kirkout, MarkC, mottdog, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:26 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0