wolfrevokcats
wolfrevokcats

Reputation: 117

iOS app memory leaks after doing Analyze in Xcode 4.5

I'm using Xcode 4.5.2 to practice iOS programming. My app seems to compile just fine, but when I do Product -> Analyze I get the following messages that are better illustrated in a

enter image description here

I'd appreciate if someone could explain this to me?

PS. I kinda understand what most that does, except the word __bridge which was suggested by a compiler and I agreed to add it.

Upvotes: 1

Views: 212

Answers (2)

Cynichniy Bandera
Cynichniy Bandera

Reputation: 6103

It is not a leak as far as you carefully track it and release in right moment. Analyser just makes a hint that function should either return autoreleased ref if someone needs it outside or release it inside the function.

Upvotes: 0

Rob
Rob

Reputation: 437422

You should use __bridge_transfer, not __bridge. You want to transfer ownership to ARC, so it will clean it up for you. Failure to do that will result in a leak.

See the discussion of toll-free bridging in the Transitioning to ARC Release Notes.

Per the WWDC 2012 notes, Apple actually suggests CFBridgingRelease. Thus:

NSString *encodedString = CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(...);

Upvotes: 3

Related Questions