Post

Replies

Boosts

Views

Activity

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: On a Sonoma machine, create a Mac OS Application Project in Xcode, using xibs and Objective-C. In the app delegate create a method: - (IBAction)leak:(id)sender { NSLog(@"LEAK!"); int* ptr = ( int* )malloc( 5 * sizeof(int) ); } In the MainMenu.xib, create a button in the window and connect it to the leak action. Build and Run. Launch Instruments and choose the Leaks tool. Attach Instruments to your running application and start recording. Click the Leak button in your app any number of times. 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: Launch Terminal export MallocStackLogging=1 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. The app will launch. Click the Leak button any number of times. 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]
2
0
667
Oct ’23