How can I see where Mail is spending its time? I don't understand what you mean with "sample Mail".
The second would be to run Object Alloc or one of the memory allocation tools to what objects are being created. Between the two, that might give some idea as to what is going on.
In ObjectAlloc I see that, with each run of my inspection method, memory allocations grow significantly for:
- NSMenuItem
- NSMenu
- CGImage
- CGDataProvider
- HIObject
- NSCarbonMenuImpl
- NSExtraMIData
(I don't list CFString, CFArray and CFDictionary allocations here...)
AXUIElement allocations are NOT growing.
As we could expect, all objects mentioned above are deallocated when a menu item in Mail is clicked.
Do you have an explanation what Mail and some other apps do here?
Does Mail cache those objects? What happens when I click a menu item?
Once you figure out the issue, though, I don't know if you would discover a workaround better than the one you've already discovered.
The "workaround" doesn't really deserve the name in my opinion, since it would present opening and closing menus to the user without giving any hint what's going on.
In my app, I call AXUIElementCopyAttributeNames() and AXUIElementCopyAttributeValue() very frequently, but as far as I can see, the resulting objects are all properly released and ObjectAlloc and MallocDebug show no indication of possible leaks.
Any idea for a workaround that doesn't have visible effects on the app?
Thanks for your help,