Skip to main content

Development

Useful build-in tools to detect performance issues of iOS Apps

When developing Apps, it is not usual but sometimes developers may face some weird issues like lagging, stuck or even App crash. Normally, those issues are caused by some bad code style or leak programming and a traditionally developer can use some third-part tools like SonarQube to ensure the code quality. Unfortunately, iOS developing uses Object-C or Swift language, which are still not as convenience as others (e.g. Java programming) and it is difficult to set up a Jenkins plus SonarQube for iOS programming. Because of that, many teams would choose to have code review meetings to analysis codes in order to try to avoid or reduce this kind of risks. Some Xcode build-in tools like Instruments is good to detect the cause of crashing or lagging, but when facing complex situations the below tools would be really helpful.

Time Profiler

It can monitor methods which are cost more time than expected in multiple threads. To make logs clean and clear, you can tick the “Hide System Libraries” in the right tab and then sort by time in the “Call Tree” area. You can also double click the “Heaviest Stack Trace” in the right are of the console to see the affected code in detail.

Allocations

In this build-in tool you can generate every action and compare the increase of the Memory, then allocate the code which cause the increase in detail. To do this you can click “Mark Generation” in the “Generation Analysis” in the right, this will create another Generation. Then you can switch to another page or wait for a while before creating one or more Generations. Compare those Generations and see the size of Growth, then try to allocate the bugs.

Leak

This is a tool to monitor the “out of memory” issues. The “out of memory” issues are very rare nowadays but you can still use the Leak and chose Statistics>Allocation Summary to ensure the App does not have such kind of issue.

Additionally, use functions/methods in the right way can avoid some performance issue. For example, when loading images in iOS apps, there are two methods to deal with UIImage: imagedNamed and imageWithContentsOfFile. iOS won’t save a cache for images using imageWithContentsOfFile but imagedNamed will do. To reduce the cost of memory, it is recommended for developers to use imageWithContentsOfFile for images which will be used once only. But using imageWithContentsOfFile will add some additional cost to Image IO when display a page or view, so please think carefully before make the decision.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Categories
Follow Us
TwitterLinkedinFacebookYoutubeInstagram