Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS: Memory leak in Cocoa_PumpEventsUntilDate #11632

Open
pminev opened this issue Dec 11, 2024 · 0 comments
Open

macOS: Memory leak in Cocoa_PumpEventsUntilDate #11632

pminev opened this issue Dec 11, 2024 · 0 comments

Comments

@pminev
Copy link

pminev commented Dec 11, 2024

While checking some apps for leak, I've detected one is happening in our demo with SDL. The same behavior was observed when I ran asyncio-load-bitmaps example with the following command:

leaks --atExit -- ./build/examples/asyncio-load-bitmaps
Show leaks log Process: asyncio-load-bitmaps [28526] Path: /Users/USER/*/asyncio-load-bitmaps Load Address: 0x102a74000 Identifier: asyncio-load-bitmaps Version: 0 Code Type: ARM64 Platform: macOS Parent Process: leaks [28525]

Date/Time: 2024-12-11 12:45:38.799 +0200
Launch Time: 2024-12-11 12:45:36.267 +0200
OS Version: macOS 15.1.1 (24B91)
Report Version: 7
Analysis Tool: /usr/bin/leaks

Physical footprint: 32.7M
Physical footprint (peak): 728.2M
Idle exit: untracked

leaks Report Version: 4.0, multi-line stacks
Process 28526: 73034 nodes malloced for 10294 KB
Process 28526: 1 leak for 32 total leaked bytes.

STACK OF 1 INSTANCE OF 'ROOT LEAK: ':
45 dyld 0x19f140274 start + 2840
44 asyncio-load-bitmaps 0x102a77d80 main + 48 SDL_main_impl.h:149
43 libSDL3.0.dylib 0x102f16190 SDL_RunApp + 60 SDL_dynapi_procs.h:804
42 libSDL3.0.dylib 0x102f2bbfc SDL_RunApp_DEFAULT + 64 SDL_dynapi_procs.h:804
41 libSDL3.0.dylib 0x102f7a538 SDL_RunApp_REAL + 88 SDL_runapp.c:40
40 asyncio-load-bitmaps 0x102a778e8 SDL_main + 64 SDL_main_impl.h:59
39 libSDL3.0.dylib 0x102f0e2d4 SDL_EnterAppMainCallbacks + 76 SDL_dynapi_procs.h:207
38 libSDL3.0.dylib 0x103176bf4 SDL_EnterAppMainCallbacks_REAL + 196 SDL_sysmain_callbacks.c:48
37 libSDL3.0.dylib 0x102f7a250 SDL_IterateMainCallbacks + 40 SDL_main_callbacks.c:125
36 libSDL3.0.dylib 0x102f34ef8 SDL_PumpEvents_REAL + 20 SDL_events.c:1413
35 libSDL3.0.dylib 0x102f34f60 SDL_PumpEventsInternal + 96 SDL_events.c:1369
34 libSDL3.0.dylib 0x103125880 Cocoa_PumpEvents + 80 SDL_cocoaevents.m:630
33 libSDL3.0.dylib 0x10312558c Cocoa_PumpEventsUntilDate + 272 SDL_cocoaevents.m:592
32 com.apple.AppKit 0x1a3a13e0c -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688
31 com.apple.AppKit 0x1a30d3a08 _DPSNextEvent + 660
30 com.apple.HIToolbox 0x1aaa1deb8 _BlockUntilNextEventMatchingListInModeWithFilter + 76
29 com.apple.HIToolbox 0x1aaa1dbb4 ReceiveNextEventCommon + 220
28 com.apple.HIToolbox 0x1aaa17f64 RunCurrentEventLoopInMode + 292
27 com.apple.CoreFoundation 0x19f5a7bc4 CFRunLoopRunSpecific + 588
26 com.apple.CoreFoundation 0x19f5a89c0 __CFRunLoopRun + 1856
25 com.apple.CoreFoundation 0x19f5c2fd8 __CFRunLoopDoTimers + 356
24 com.apple.CoreFoundation 0x19f5c34c8 __CFRunLoopDoTimer + 1012
23 com.apple.CoreFoundation 0x19f5c3824 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 32
22 com.apple.HIToolbox 0x1aaad27a8 CallMyActivateTSMDocument + 116
21 com.apple.HIToolbox 0x1aaab928c MyActivateTSMDocument + 2080
20 com.apple.HIToolbox 0x1aaabd574 utOpenActivateAllSelectedIMInDoc + 200
19 com.apple.CoreFoundation 0x19f56b004 CFArrayApplyFunction + 72
18 com.apple.HIToolbox 0x1aaabd6c4 utOpenActivateAllSelectedIMInDocIterator + 32
17 com.apple.HIToolbox 0x1aaabd8a0 utOpenActivateSelectedInputMethodInDoc + 256
16 com.apple.HIToolbox 0x1aaad5114 CreateInputMethodInstance + 364
15 com.apple.HIToolbox 0x1aaad5fb8 IMKInputSessionCreate + 268
14 com.apple.HIToolbox 0x1aaad6060 GetIMKClient(NSString*, bool, bool) + 120
13 com.apple.HIToolbox 0x1aab243cc -[IMKClient_Modern initWithBundleIdentifier:isIMKExtension:] + 136
12 libdispatch.dylib 0x19f311ea0 _dispatch_once_callout + 32
11 libdispatch.dylib 0x19f310658 _dispatch_client_callout + 20
10 com.apple.HIServices 0x1a5e8a5e4 _HIRLU_AddRunLoopModeForDeferredActions + 80
9 com.apple.HIServices 0x1a5e87ff8 +[HIRunLoopUtilities addRunLoopModesForDeferredActions:] + 132
8 com.apple.HIServices 0x1a5e88078 whileHoldingLockPerform(os_unfair_lock_s*, void () block_pointer) + 48
7 com.apple.HIServices 0x1a5e88124 __56+[HIRunLoopUtilities addRunLoopModesForDeferredActions:]_block_invoke + 92
6 com.apple.CoreFoundation 0x19f5b4930 -[__NSPlaceholderSet initWithSet:copyItems:] + 176
5 com.apple.CoreFoundation 0x19f5b4c2c -[NSSet initWithSet:copyItems:] + 568
4 com.apple.CoreFoundation 0x19f535f60 __NSSingleObjectSetI_new + 48
3 com.apple.CoreFoundation 0x19f530af8 __CFAllocateObject + 20
2 libobjc.A.dylib 0x19f0efa44 class_createInstance + 72
1 libsystem_malloc.dylib 0x19f2e7af8 _calloc + 88
0 libsystem_malloc.dylib 0x19f2fa9bc _malloc_zone_calloc_instrumented_or_legacy + 128

    1 (32 bytes) ROOT LEAK: <NSSet 0x133289860> [32]

I tried to wrap [Cocoa_PumpEventsUntilDate](https://github.com/libsdl-org/SDL/blob/7c5c88a3adb65f066a27b78714f1e4676107cd59/src/video/cocoa/SDL_cocoaevents.m#L577) in autoreleasepool but that didn't help. Since the leaked object was from [NSApp nextEventMatchingMask... function call I suppose it comes from apple libraries, but not completely sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant