Mobile Development 7 min read

iOS Memory Performance Testing: Static and Dynamic Analysis Tools

This article explains iOS memory performance testing by covering static analysis via Xcode's Analyze feature and dynamic analysis tools such as Leaks, Activity Monitor, Allocations, and Zombies, illustrating how to detect memory leaks, unreasonable memory usage, and EXC_BAD_ACCESS errors with practical examples and step‑by‑step guidance.

Baidu Intelligent Testing
Baidu Intelligent Testing
Baidu Intelligent Testing
iOS Memory Performance Testing: Static and Dynamic Analysis Tools

Background: Performance testing is essential for iOS developers; unoptimized code can cause lag or crashes.

Static analysis: In Xcode, long‑press the Run button and select Analyze to run static analysis, which checks for logical errors, memory‑management errors, unused variables, and API misuse. It is required for MRC projects and optional for ARC projects.

Dynamic analysis tools: Instruments provides several tools for runtime memory inspection:

Leaks – detects memory that has been allocated but is no longer referenced.

Activity Monitor – shows real‑time memory usage; if Real Mem does not decrease after leaving a page, a leak may exist.

Allocations – reveals how much memory each object type consumes, useful for identifying unreasonable memory usage (abandoned memory).

Zombies – replaces deallocated objects with “zombie” placeholders to catch EXC_BAD_ACCESS errors caused by messages sent to freed objects.

The article demonstrates how to locate leaks using the Leaks instrument, interpret the red arrows in the screenshot, and navigate from Call Trees to the offending code.

It also explains the difference between memory leaks (unreferenced allocated memory) and unreasonable memory usage (objects kept in cache but never used), and recommends using the Allocations instrument when the app receives a memory warning.

For EXC_BAD_ACCESS debugging, the Zombies tool can be enabled manually by setting the environment variable NSZombieEnabled = YES , or more conveniently by selecting the Zombies template in Instruments. The guide outlines the steps: launch Instruments, choose Zombies, run the test case that crashes, examine the call stack and history to pinpoint the offending object.

Sample code illustrating a crash without ARC:

NSString* hello = [NSString stringWithFormat:@"Hello"];
NSLog(@"What you say is%@", hello);
[hello release];

When ARC is enabled, such crashes are largely avoided, though they can still occur with unmanaged C++ code.

The article concludes by announcing upcoming parts covering CPU, stutter, network, and battery performance testing.

iOSperformance testingmemoryStatic AnalysisDynamic AnalysisinstrumentsZombies
Baidu Intelligent Testing
Written by

Baidu Intelligent Testing

Welcome to follow.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.