12 Replies
      Latest reply on Aug 3, 2019 10:36 AM by infinibit
      mark7 Level 1 Level 1 (0 points)

        After updating to Xcode 10.2, I’ve started getting random leaks in Instruments.  Just creating a new default single view app and profiling on a physical device iPad or iPhone shows random leaks. I completely uninstalled the update and tried again and the same is happening.


        If I use the Memory Graph Debugger everything is good.


        Any recommendations on how to fix?


        Update -

        Ended up doing a clean install of Mojave 10.14.4 and Xcode 10.2, still getting the same results.

        • Re: Instruments Leaks
          KMT Level 9 Level 9 (15,785 points)

          Quoting Xcode 10.2 release notes:


          Clang Static Analyzer


          Resolved Issues

          • The static analyzer now warns when a C++ object is used after its contents are moved unless the object is reset to a known state before it’s used. (41349073)
          • The static analyzer now checks for violations of IOKit and libkern reference counting rules. These violations can lead to leaks and use-after-free issues.
          • Re: Instruments Leaks
            AncientCoder Level 1 Level 1 (10 points)

            I filed a bug report for this a few weeks ago.  I had correspondence with the engineers for a few days, providing further information, but heard nothing since.  The bug is still listed as open.

            • Re: Instruments Leaks
              Luxo Level 1 Level 1 (0 points)

              Still there in Xcode 10.2.1. Firing up a fresh iOS or macOS app template and profiling in Instruments shows 100s of leaks after a minute or so. They look to be false positives. I don’t see the memory use going up, but makes looking for actual issues harder. Clicking through to the detail view on a leaked object and I’m seeing the ref count column contains occasional negative ones – I don’t think it should do that – so something appears off somewhere.

              • Re: Instruments Leaks
                infinibit Level 1 Level 1 (0 points)

                Noticed that XCode 10.2.1 + iOS 12.1.2 does not generate leaks while XCode 10.2 + iOS 12.2 or 12.3 does generate numerous leaks in the Leaks instrument.  Update: Just performed a simple test using the "Hello Triangle" example from the Metal tutorials.  With XCode 10.2.1, iOS 12.3, under Obj-C, and no changes to the code provided in the example, the leaks instrument immediately begins showing leaks.  Here is the link to the example application: https://developer.apple.com/documentation/metal/using_a_render_pipeline_to_render_primitives?language=objc

                • Re: Instruments Leaks
                  fluxom Level 1 Level 1 (0 points)

                  I've get over 100 leaks in Instruments when testing a default Swift project in XCode 10.3 and iOS 12.2 target.


                  I've submitted to Apple and written on Stackoverflow to see what is going on. So far, I've heard nothing. This has been an issue for quite a while.


                  What is everyone doing to deal with the false positives?




                    • Re: Instruments Leaks
                      infinibit Level 1 Level 1 (0 points)

                      I am downloading XCode 10.3 now, will see if it resolves the false positives on iOS 12.2 & 12.3 for Obj-C.  In the meantime I was lucky enough to have a device with iOS 12.1.2 running that I could leak check my code on ( XCode 10.2.1 + IOS 12.1.2 is not showing the same framework leaks / false positives ).  So if you have a device running an older version of iOS 12.1.2 that might be a way to differentiate the false positives from real leaks.  Will update once I run some tests on XCode 10.3 + iOS 12.x.  Fingers crossed.


                      **Update** Just ran a few quick tests: 1) iOS 12.3.1 + Xcode 10.3 still shows numerous leaks in various core frameworks.  2) iOS 12.1.2 + Xcode 10.3 running exact same code shows no framework leaks.  3) There seems to be an iOS12.4 update available, next step is to try combo of XCode 10.3 + iOS 12.4 and see if the problems is eliminated.  Will update when I get a chance to give it a try.


                      **Update** XCode 10.3 + iOS 12.4 resolves the issue for OBJ-C Metal & AVAudioEngine application in my testing.

                    • Re: Instruments Leaks
                      infinibit Level 1 Level 1 (0 points)

                      Good news everyone, from my testing, for Obj-C Metal + AVAudioEngine application, Xcode 10.3 + iOS 12.4 resolves the false positives seen in the leaks instrument that many were previously experiencing on iOS 12.3 & 12.2 + XCode 10.2.1.  Curious if anyone can test with Swift and report the results.