Developers always look for the ways to improve their app’s performance. For this they should always profile their app. Instruments is a powerful performance tuning app shipped with Xcode. It has many templates to profile for like - CPU usage, memory usage, leaks, network usage, file usage, energy usage etc.


Memory leaks are one of the most overlooked issues while submitting apps to the app store. Memory leaks can grow when user continuously uses the app and may result in app crash. (Out of memory situation)


While using the app, memory usage should not grow continuously. The app must release allocated memory when the resources of the app are no longer in use.

Leaks template in Instruments helps to see memory leaks in the app.

Below are the steps to perform memory profiling on the app –

1. Select Open Developer Tools -> Instruments from Xcode menu.



2. Select Device/Simulator and Target app on top the template window



3. Select Leaks template and click choose


This will bring the instruments window with allocation and leaks information to show



4. Select Record button to start profiling for the app


This will start the app in the selected Device / Simulator. As you will use the app, instruments will record the allocation and leaks information about the different resources of the app.


Each green check mark shows No memory leak in the app, while the user was playing around the app. And each red mark shows Memory leaks


5. Clicking on the red diamond will show the Leaks by Backtrace



Parts in the gray color in stack trace are system libraries and parts in black color are app’s code.



6. Double click on the black color part (App’s code) will show the code which was causing the leak



By analyzing those code snippets we can remove memory leaks and rerun profiling on the app.



Profiling apps for memory leaks would help users to understand, retain cycles and will help in resolving the leaks.

Memory leaks don’t show immediate effect on the app but when these leaks grow, they may cause crash in the app.

Instruments helps to improve the performance and stability of the app.


Hope this blog would help. Happy Profiling J