Not all leaks appear in the Leaks tool in the Tools. And, especially, if the view controller has a strong reference loop, the controller will not be released not only, but not one of its members will be released. But, looking at your distributions, your memory is never freed, so you probably have a leak somewhere. It's hard for us to diagnose because your github project is incomplete. But here are a few thoughts:
Strong link loops are not always displayed in the Leaks tool.
According to the traditional strong reference loop, your code uses a repeating NSTimer
that will contain a strong link to your view controller, which will cause your view controller to never be released (as the timer maintains its own link to your view controller). To fix this, your view controller should stop the timer when the corresponding view disappears:
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; self.timer = [NSTimer scheduledTimerWithTimeInterval: 0.05f target: self selector: @selector(tick) userInfo: nil repeats: YES]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self.timer invalidate]; self.timer = nil; }
Besides strong reference cycles, such as the one above, another phenomenon that can lead to an increase in the distribution, as you shared with us, is a circular flow between view controllers. For example, if your application does push / modal segue from view controller A to view controller B, the application should then pop / fire / cancel back to view controller A. If you press / modal from B to a new instance of A, you end up as a result, abandon your old instance of A, as a result, get a distribution graph like yours.
These are just a few examples of the things that can lead to your distribution schedule. But it’s hard for us to diagnose further information with limited information.
Before doing anything else, use the Xcode static analyzer ( command + shift + B or "Analysis" in the "Product" menu) and make sure there is a clean account there. Let Xcode help you identify your programming problems in your code.
Once you fix all the problems identified by the static analyzer, you can immerse yourself in Tools. See WWDC 2012 Video, iOS Application Performance: Memory . After about 32 minutes, it shows a distribution chart similar to yours, describes three sources of such problems (leaks, left memory, or cached memory) and shows how to use the Allocations tool to determine the exact source of the problem.
You have to follow this video and you will probably learn about the functions of the Allocations tool (such as comparing heap snapshots) to determine which object has leaked, or look at the extended information and the call tree to find the source code that the leaked object was created. Once you determine exactly what the leak is, we can help you solve the problem.
By the way, it’s even simpler than the heaps described in this video, I will often just option -click-and-drag on a specific spike (especially one that is obviously never released) on the chart in "Allocations". If you do this, the final summary of the object will show you the objects (most useful if you sort by "Live Bytes") that were highlighted and not released during this run window:

This may be useful, but sometimes it’s just a cryptic CFString
or CGImage
distribution. Therefore, it is sometimes useful to see where these objects were allocated in your code. If you go from “Statistics” - “Object Summary” to “Call Tree”, it will show you how much memory was occupied by each of your methods (and I find this screen most useful if I also check “Invert Call Tree” and "Hide system libraries"):

If you then double-click on the symbol name here, it will actually show you code that violates:

In this process, I can see what is allocated on this surge, and now I can determine why this memory is never freed (in this case it was my intentional use of a repeating timer, T24>).
There are other tricks that are useful in more complex scenarios (I especially like to have code signaling flags that appear in the tools, so I can more accurately match the actions in my code with what happens in the Tools), but this is probably too much to enter here. We hope this tool option -cick-and-drag in the tools becomes a useful tool for determining what is highlighted and never released.