Using Instrument Leaks to detect memory leaks for iOS project iOS 16.1

I am facing an issue trying to detect a memory leak for iOS project with any Simulator for iOS 16.1 on Xcode 14.1

I am working on an example app https://github.com/Showmax/automated-memory-leak-testing-ios

That simply creates a memory leak using a strong delegation between Two classes

The expectation: when using the memory debug graph I am expecting that Xcode will mark the instance of GeneratorViewController that have a leak as a leak.

Behavior: It doesn't

The same behavior is happing when I am using the instrument tool with the defaults Leaks template.

I only see can see tons of leaks when I use Simulator iOS 14 which I am not sure why it's different.

Can you please support? Thanks

Post not yet marked as solved Up vote post of ayman.karram Down vote post of ayman.karram
1.8k views

Replies

Thanks for reaching out!

It looks like this is an issue with the leak detection logic used by the Leaks instrument and the leaks command-line tool.

Based on a bit of investigation, it looks like view controller you expect to be reported as leaked is being weakly referenced by NotificationCenter as a notification observer. It looks like the leak detection logic isn't detecting these references' scan types (weak) and so we scan them conservatively (assuming they're owning references). This causes us to incorrectly report that NotificationCenter allocations have owning references to your objects, and that your objects aren't leaked.

You can see this for yourself using the Memory Graph Debugger in Xcode to look at incoming references to instances of GeneratorViewController.

Please file a bug about this using Feedback Assistant, giving steps to reproduce the issue and a link to the example app.

Thank you for the reply, unfortunately, my goal is to run the instrument tool on CI and read .trace file, so I can send notifications for leaks to related code owners to check the leaks. So I can't really depend on Memory Graph Debugger.

  • I only mentioned the Memory Graph Debugger as a way of observing the cause of the bug you're seeing. The Memory Graph Debugger, Leaks instrument, and leaks CLI tool all use the same techniques for identifying leaks, so you'll see the same issue in the Memory Graph Debugger that you're seeing with the Leaks instrument.

    Again, please consider filing the bug using Feedback Assistant.

  • Thank you for the clarification. I filled a feedback https://feedbackassistant.apple.com/feedback/12057817

Add a Comment

Any idea how the process of the feedback will go? as I didn't see any reponse https://feedbackassistant.apple.com/feedback/12057817