Re: Memory leak in NSOutlineView?
Re: Memory leak in NSOutlineView?
- Subject: Re: Memory leak in NSOutlineView?
- From: Andreas Schwarz <email@hidden>
- Date: Wed, 3 Apr 2002 11:16:11 -0800
I'm pretty sure you are running into a known bug; you might search the
archives to get more info on it.
I thought I remembered someone mentioning something similar, but I did
search the archives for nearly an hour without any luck.
Apparently, whenever an item is expanded, it is retained, and isn't
released until it is collapsed again.
... or until the outline view itself is deallocated.
Obviously. But when the OV sticks around for the life of the app, that
doesn't do much good ;-).
This in itself
wouldn't be too annoying, except that calling collapseItem:(root item)
collapseChildren:YES doesn't work. I do get notifications that the
children have been collapsed, but they aren't released. They have to
be
collapsed individually in order to be released.
Yup, same bug. If you want some handy code to collapse recursively,
look in OmniAppKit. (Specifically NSOutlineView-OAExtensions,
-collapseItemAndChildren:.) It's not really that hard.
That code goes through and recursively collapses all the children of
every item regardless of whether the item is expanded or not. This is
good as far as it'll find and collapse any uncollapsed children of an
item that was once expanded but had since been collapsed, but in my case
it is horribly inefficient and will likely run into some infinite loops.
Since it checks every possible path, depending on what part of the
filesystem the user has it set to display it may have to load and check
a huge number of children (and if there is any sort of circular loop
caused by aliases, it will go on loading them forever!).
My current code only collapses those items that are currently expanded,
but of course that causes leaks wherever there are children of a
now-collapsed item that are still expanded. I guess I will add a
"wasEverExpanded" boolean to the items and have it check for that as it
collapses items. Rather a pain :-\.
Thanks,
Andreas Schwarz
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.