iOSProgrammingIsFun
iOSProgrammingIsFun

Reputation: 1458

Memory Leak - NSString & NSURL

@property ( nonatomic, strong ) NSURL * urlPath;

self.urlPath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"bark" ofType:@"caf"]];

Running ARC, deployment target 4.3. Instruments gives a leak on the self.urlPath = line.

The self.urlPath is used later on after the view has appeared to setup the AVSoundPlayer. There is NO leak indicated now on the soundplayer, only on this NSURL line. The audio plays, but when the view is pop'd a memory leak occurs.

Any ideas as I've been at this > 12hrs now...

Upvotes: 1

Views: 1522

Answers (2)

iOSProgrammingIsFun
iOSProgrammingIsFun

Reputation: 1458

Seems to be a memory leak in Core Foundation only in iOS 6.

Therefore filed as a bug:

Bug ID# 12699818.

Upvotes: 2

jimpic
jimpic

Reputation: 5520

Your player is leaking, and if your player leaks, every player will keep their URL and string object too.

self.player = [[[AVAudioPlayer alloc] initWithContentsOfURL:pingURL error:nil] autorelease];

If you declared player as a retaining property, then

self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:pingURL error:nil];

will leave the reference count at 2.

self.player = nil;

will make it 1.

Upvotes: 0

Related Questions