I have an NSMenu which contains a number of dynamic items. These items are created in NSMenuDelegate's menuNeedsUpdate method and are each assigned a representedObject. I'm looking to trim the object graph and hopefully regain a bit of memory when the menu is closed by removing all dynamic items (and having them recreated when the menu is re-opened). The issue I'm having is knowing exactly where and how this should be handled.
The documentation states that NSMenu's menuDidClose is not a suitable place to update the contents of a menu. I've setup a notification to listen for NSMenuDidEndTrackingNotification and am removing the dynamic items at that point with a call to my NSMenu's removeItem: method. Is this the correct way to handle this situation?
Finally, can I be assured that calling removeItem on an NSMenuItem will correctly nullify any custom views that may be assigned to it, as well as any submenus?