NEW: Learn to build the incredible iOS 15 Weather app today! >>

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?

   

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.

1      

Hacking with Swift is sponsored by Sentry

SPONSORED With Sentry’s error and performance monitoring for iOS, you see mobile vitals that actually matter, can solve any latency issues quickly, and learn how each release is performing over time.

Learn More

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

Reply to this topic…

You need to create an account or log in to reply.

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.