Instruments 8.3 beta: false positive leak reported

Number:rdar://31154770 Date Originated:20-Mar-2017 04:29 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Instruments 8.3 beta (8W143q)
Classification:Serious Bug Reproducible:Always
The attached code will report a leak in Instruments, but as far as I can determine, it is a false positive. Thanks to and for helping me to track it down.

Steps to Reproduce:
1. Open the attached sample code in Xcode 8.3 beta 4 (8W143q).
2. Run the app in Instruments on the iPhone simulator (I used iPhone SE), iOS 10.3.
3. Choose the Leaks instrument.
4. Start recording.

Expected Results:
No leaks are reported.

Actual Results:
A leak is reported. Then:
1. Observe the reported leak is of type _ContiguousArrayStorage<Bool>.
2. Click the arrow in a circle (what’s that called?) next to the memory address to view details about the leak.
3. Observe that it got a +1 ref count via Malloc, and that’s it.
4. In the iOS simulator, click the “Nil the Container” button.
5. In Instruments, click back out to the Leaks by Backtrace view, since the individual leak doesn’t seem to update automatically.
6. Click the disclosure arrow thingy next to the address again.
7. Observe that it has now received a balanced pair of +/- ref counts via Malloc and then Release, and that it then proceeds to Free. This means that it was never a leak, because it existed while its parent existed, and was deallocated when its parent was deallocated. Therefore, Instruments is reporting a false positive leak.

Unknown. Reproducible in Xcode 8.2.1.

Sample code:
Video of reproduction:

Here is a list of interesting things that you can change in the code, any one of which will cause the false leak report to disappear:
1. Comment out ViewController.swift:34, which mutates the array storage of the struct.
2. Change MyTrivialEnum to have one case instead of two.
3. Move the declaration of leakyContiguousAraryStorage to the top of the ProblemType struct instead of the bottom.
4. Comment out any of the a, b, c, d, or e variables in the ProblemType struct. With four or fewer, it does not report a leak, but with five, it reports a leak.
5. Change the type of FillerType from MyTrivialEnum to any of Bool, Int, Int8, or Int16.

Those last few make it seem like memory layout or alignment are implicated somehow.

This may seem like a rare issue, but I’m reporting it because we encountered it in a real-world type:


Post by me, August 14th 2019, 6:21 PM

I don’t believe the issue is solved. It’s hard to tell because, in Xcode 11 beta 5, I can’t get the app to launch from Instruments. See attached video. However, the memory graph debugger is reporting the same leak as before.

Attached files also posted here for posterity: Sample project updated for Xcode 11 beta 5: Video recording of reproduction of issue:

Message from Apple, August 13th 2019, 3:05 AM

After reviewing your feedback, we need more information to continue our investigation.

Please verify this issue with Xcode 11 beta 5 and update your bug report with your results by logging into ( or by using the Feedback Assistant app.

Xcode 11 beta 5 (11M382q) Posted Date: July 29th, 2019

For a complete list of logging instructions visit:

This radar is now also known as FB5759313

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!