UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Can I ignore this memory leak?

Forums > Swift

I'm getting 'x instances of NSCFString leaked'. When I try to backtrace them using Memory Graph Hierarchy, they all appear on the @main line of the app.

I'm new at analysing memory allocation so I'm really in doubt if I should just ignore them because they are caused by some internal type. I've managed to solve other leaks that were caused by me, but with this one I'm really struggling to even find if I caused it or not.

Besides that, what would be your tip for when to ignore a leak and when to dig deep into it?

3      

This is an excellent question.

Frankly, my long experience with high volume servers leads me to believe that one should never ignore a memory leak.

That said, I've found leaks inside core libraries and reported them to Apple, who's done nothing about them. So, even if you find the leak and it isn't yours, you may not be able to do anything.

If it were me, I'd track it down until I could either fix it or point to the library that is doing the leaking, and in the latter case file a bug report. At the very least, you will have written down where the leak happens so that if some other poor soul starts wondering what's up, they'll be able to find your notes.

5      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.