Leaks Instrument Does Not Find Leaks on Sonoma

The Leaks Instrument in Sonoma never reports any leaks. This is happening on Sonoma only. Instruments on Ventura reports the leaks appropriately.

This feels like a bug in Instruments on Sonoma, but I wanted to check in here to see if maybe I'm doing something wrong.

Steps to dupe:

  1. On a Sonoma machine, create a Mac OS Application Project in Xcode, using xibs and Objective-C.
  2. In the app delegate create a method:
- (IBAction)leak:(id)sender
{
    NSLog(@"LEAK!");
    int* ptr = ( int* )malloc( 5 * sizeof(int) );
}
  1. In the MainMenu.xib, create a button in the window and connect it to the leak action.
  2. Build and Run.
  3. Launch Instruments and choose the Leaks tool.
  4. Attach Instruments to your running application and start recording.
  5. Click the Leak button in your app any number of times.
  6. Stop recording in Instruments.

RESULT: Instruments reports no leaks found.

WORKAROUND: To see leaks on Sonoma I can do so in the Terminal using leaks with these steps:

  1. Launch Terminal
  2. export MallocStackLogging=1
  3. leaks -atExit -- /Users/zack/Library/Developer/Xcode/DerivedData/Leaker-fkhkydpehobufngumikoydtpyxsc/Build/Products/Debug/Leaker.app/Contents/MacOS/Leaker NOTE: this leaks command takes the path to the actual built binary.
  4. The app will launch.
  5. Click the Leak button any number of times.
  6. Quit the app.

For example, clicking the Leak button 7 times, the leaks tool reports:

STACK OF 7 INSTANCES OF 'ROOT LEAK: <malloc in -[AppDelegate leak:]>':
19  dyld                                  0x183e39058 start + 2224
18  ZJ.Leaker                             0x10207d12c main + 60  main.m:14
17  com.apple.AppKit                      0x187a33708 NSApplicationMain + 880
16  com.apple.AppKit                      0x187a5c460 -[NSApplication run] + 512
15  com.apple.AppKit                      0x187e8f1bc -[NSApplication _handleEvent:] + 60
14  com.apple.AppKit                      0x18823bc08 -[NSApplication(NSEventRouting) sendEvent:] + 1556
13  com.apple.AppKit                      0x187b9482c -[NSWindow(NSEventRouting) sendEvent:] + 284
12  com.apple.AppKit                      0x187b94b6c -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 364
11  com.apple.AppKit                      0x187c093b4 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 3472
10  com.apple.AppKit                      0x187c0a5e8 -[NSControl mouseDown:] + 448
9   com.apple.AppKit                      0x187c0b114 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 488
8   com.apple.AppKit                      0x187c0b25c -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 144
7   com.apple.AppKit                      0x187c0b850 NSControlTrackMouse + 1480
6   com.apple.AppKit                      0x187c0e220 -[NSButtonCell _sendActionFrom:] + 88
5   com.apple.AppKit                      0x187c0e2fc -[NSCell _sendActionFrom:] + 204
4   com.apple.AppKit                      0x187c0e3d4 __26-[NSCell _sendActionFrom:]_block_invoke + 100
3   com.apple.AppKit                      0x187c0e490 -[NSControl sendAction:to:] + 72
2   com.apple.AppKit                      0x187c0e68c -[NSApplication(NSResponder) sendAction:to:from:] + 460
1   ZJ.Leaker                             0x10207d2b8 -[AppDelegate leak:] + 88  AppDelegate.m:34
0   libsystem_malloc.dylib                0x183ff4ad0 _malloc_zone_malloc_instrumented_or_legacy + 276 
====
    7 (224 bytes) << TOTAL >>
      1 (32 bytes) ROOT LEAK: <malloc in -[AppDelegate leak:] 0x600000ca5bc0> [32]
      1 (32 bytes) ROOT LEAK: <malloc in -[AppDelegate leak:] 0x600000ca6e80> [32]
      1 (32 bytes) ROOT LEAK: <malloc in -[AppDelegate leak:] 0x600000ca74a0> [32]
      1 (32 bytes) ROOT LEAK: <malloc in -[AppDelegate leak:] 0x600000cb8520> [32]
      1 (32 bytes) ROOT LEAK: <malloc in -[AppDelegate leak:] 0x600000cc0840> [32]
      1 (32 bytes) ROOT LEAK: <malloc in -[AppDelegate leak:] 0x600000cc09a0> [32]
      1 (32 bytes) ROOT LEAK: <malloc in -[AppDelegate leak:] 0x600000cc7a00> [32]
Answered by Developer Tools Engineer in 767105022

Hi!

We recently identified and resolved a bug where Instruments failed to report leaks. Can you try again with the copy of Instruments bundled with Xcode 15.1 beta 1 and let us know if it is still happening? From the release notes:

Fixed: Leaks instrument never detects leaks. (115440742)

Accepted Answer

Hi!

We recently identified and resolved a bug where Instruments failed to report leaks. Can you try again with the copy of Instruments bundled with Xcode 15.1 beta 1 and let us know if it is still happening? From the release notes:

Fixed: Leaks instrument never detects leaks. (115440742)

Thanks! The Xcode 15.1 beta 1 fixed the issue. Thanks, again!

Leaks Instrument Does Not Find Leaks on Sonoma
 
 
Q