NSTreeController not deallocating NSTreeNodes and attached objects
| Originator: | jum | ||
| Number: | rdar://18982529 | Date Originated: | 2014-11-14 |
| Status: | Open | Resolved: | |
| Product: | OS X | Product Version: | 10.10 |
| Classification: | Serious Bug | Reproducible: | Always |
We have a bug report in our application that memory is not freed when deleting nodes from an outline view. I have reproduced the issue with a small sample app. The class used as the object model has log messages on init and dealloc, so you'll be able to see which objects get deallocated. Also, there's a global allocation count displayed in the app window. Under certain circumstances the tree nodes are not deallocated. I'm not entirely sure why, but the steps below will allow to reproduce: Steps to Reproduce: - Build and run sample app - press "Add" button to create root node - press "Add Child Hierarchy" button to add a child items with one sub-item - disclose the new child item, but don't change selection (important!) - disclose the new child item's child, but don't change selection (important!) - delete the new child item by pressing the "Remove" button Expected Results: All model objects (OutlineObject class instances) and NSTreeNode objects that are contained in the deleted object should be deallocated. Actual Results: Only the object that was selected when the "Remove" button was pressed is actually deallocated, the child items are not deallocated. Notes: When changing the selection and selecting each child item at least once, all child items are deallocated when removing the container item. The way we add child items in this case is to modify the model in a KVO-compliant way. The changes are propagated to the NSTreeController / NSTreeNodes via KVO. Since the changes are displayed, I assume that this way should work correctly.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!