Mayank Gupta👨‍💻🥑
Mayank Gupta👨‍💻🥑

@iosmayank

9 Tweets 21 reads Feb 04, 2023
3 PRO techniques to find Memory Leaks in iOS project🔥
A thread🧵
📌 What is Memory Leak?
A memory leak is a situation in an iOS app when memory that is no longer in use is not properly cleared and continues taking up space. This can hurt app performance, and eventually, when the app runs out of available memory, will cause a crash.
📌 Techniques to find Memory Leaks you must know
1. Allocations and Leaks Instrument
2. Symbolic Breakpoint
3. Debug Memory Graph
⭐️ ONE BONUS TIP at the end
📌 Allocations and Leaks Instrument
For memory issues, we usually use Allocations and Leaks tools, comes with Intruments in Xcode. It tracks all of the objects that app allocates over the course of its run, Leaks instrument checks all memory and figures out the leaked objects.
📌 Symbolic Breakpoint
Xcode Instruments is a great tool for finding memory leaks but we can continuously monitor memory leaks by creating a symbolic breakpoint. This listens to the view controller’s dealloc method & check if the view controller was deallocated from memory.
📌 Debug Memory Graph
Xcode offers us a native way — debug memory graph to detect memory leaks. It is a tool first introduced in Xcode 8 and is able to grab leaks such as retain cycles. What you need to do is just click memory debug button in Xcode’s debug bar.
📌 Time for a BONUS TIP
A great rule of thumb is to always use `weak` or `unowned` when dealing with closures or delegates.
Use some type of linter, like SwiftLint. You can detect issues at compile time and it helps automate code style for your team.
Congratulations🥳
You earned a MEMORY LEAKS SAVIOUR BADGE🎖
Today, you learned how to find the Memory Leaks in your iOS project and prevent it from any potential crash and performance issues in the future.
That's all for this thread!
If you found this helpful:
1. Follow me @iosmayank for more such content
2. Retweet the first tweet

Loading suggestions...