Modal loop memory leak on 10.6
Modal loop memory leak on 10.6
- Subject: Modal loop memory leak on 10.6
- From: Jo Meder <email@hidden>
- Date: Mon, 20 Dec 2010 23:04:03 +1300
Hi,
On 10.6.5 I'm seeing a runaway memory leak in my app when I show a modal dialog. I'm not seeing the leak in the same situation on 10.5. The modal loop is run using [NSApplication runModalSession:].
Using Instruments to look at allocations I'm seeing that many instances of CFArray, NSConcreteNotification and CFRunLoopObserver are being allocated and not disposed of. Here some stack crawls:
For CFArray:
38 58.03 MB CFArray :0
37 CoreFoundation 58.03 MB _CFRuntimeCreateInstance
36 CoreFoundation 58.03 MB __CFArrayInit
35 CoreFoundation 46.43 MB __CFXNotificationPost
34 CoreFoundation 46.43 MB _CFXNotificationPostNotification
33 Foundation 46.43 MB -[NSNotificationCenter postNotificationName:object:userInfo:]
32 CoreFoundation 23.21 MB -[NSArray makeObjectsPerformSelector:]
31 AppKit 23.21 MB -[NSApplication(NSWindowCache) _updateWindowsUsingCache]
30 AppKit 23.21 MB -[NSApplication updateWindows]
29 AppKit 23.21 MB _handleWindowsNeedUpdateNote
28 CoreFoundation 23.21 MB __CFRunLoopDoObservers
27 CoreFoundation 23.21 MB __CFRunLoopRun
26 CoreFoundation 23.21 MB CFRunLoopRunSpecific
25 HIToolbox 23.21 MB RunCurrentEventLoopInMode
24 HIToolbox 23.21 MB ReceiveNextEventCommon
23 HIToolbox 23.21 MB BlockUntilNextEventMatchingListInMode
22 AppKit 23.21 MB _DPSNextEvent
21 AppKit 23.21 MB -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
20 AppKit 23.21 MB -[NSApplication _realDoModalLoop:peek:]
19 AppKit 23.21 MB -[NSApplication runModalSession:]
18 tglib 23.21 MB UnderC::details::UCMacEventManagerImp::RunModalLoopForDialog(UnderC::UCDialog const&)
17 tglib 23.21 MB UnderC::UCEventManager::RunModalLoopForDialog(UnderC::UCDialog const&)
For NSConcreteNotification:
38 46.43 MB NSConcreteNotification :0
37 libSystem.B.dylib 46.43 MB calloc
36 libobjc.A.dylib 46.43 MB _internal_class_createInstanceFromZone
35 Foundation 46.43 MB NSAllocateObject
34 Foundation 46.43 MB +[NSConcreteNotification newTempNotificationWithName:object:userInfo:]
33 Foundation 46.43 MB -[NSNotificationCenter postNotificationName:object:userInfo:]
32 CoreFoundation 23.21 MB -[NSArray makeObjectsPerformSelector:]
31 AppKit 23.21 MB -[NSApplication(NSWindowCache) _updateWindowsUsingCache]
30 AppKit 23.21 MB -[NSApplication updateWindows]
29 AppKit 23.21 MB _handleWindowsNeedUpdateNote
28 CoreFoundation 23.21 MB __CFRunLoopDoObservers
27 CoreFoundation 23.21 MB __CFRunLoopRun
26 CoreFoundation 23.21 MB CFRunLoopRunSpecific
25 HIToolbox 23.21 MB RunCurrentEventLoopInMode
24 HIToolbox 23.21 MB ReceiveNextEventCommon
23 HIToolbox 23.21 MB BlockUntilNextEventMatchingListInMode
22 AppKit 23.21 MB _DPSNextEvent
21 AppKit 23.21 MB -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
20 AppKit 23.21 MB -[NSApplication _realDoModalLoop:peek:]
19 AppKit 23.21 MB -[NSApplication runModalSession:]
18 tglib 23.21 MB UnderC::details::UCMacEventManagerImp::RunModalLoopForDialog(UnderC::UCDialog const&)
17 tglib 23.21 MB UnderC::UCEventManager::RunModalLoopForDialog(UnderC::UCDialog const&)
For CFRunLoopObserver:
24 27.08 MB CFRunLoopObserver :0
23 CoreFoundation 27.08 MB _CFRuntimeCreateInstance
22 CoreFoundation 27.08 MB CFRunLoopObserverCreate
21 AppKit 27.08 MB -[NSApplication setWindowsNeedUpdate:]
20 AppKit 27.08 MB -[NSApplication _realDoModalLoop:peek:]
19 AppKit 27.08 MB -[NSApplication runModalSession:]
18 tglib 27.08 MB UnderC::details::UCMacEventManagerImp::RunModalLoopForDialog(UnderC::UCDialog const&)
17 tglib 27.08 MB UnderC::UCEventManager::RunModalLoopForDialog(UnderC::UCDialog const&)
It looks like it's something to do with updating windows. It just keeps allocating these objects until after a fairly short time it crashes when it runs out of address space. It's growing in 20 MB steps as you watch it.
I have a smaller testbed app for testing my GUI framework and a modal dialog shown in the same way doesn't show the same memory leak that doing it in the main app does, so it could well be something to do with my code. However has any seen this sort of behaviour before and have any pointers as to what might be going awry? I'm out of ideas at the moment.
Regards,
Jo Meder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden