You should look more at your design. Having that many objects being unobserved and reobserved (your word although in the context of new objects) reminds me of what I've called a genocidal refresh, an antipattern that can be fixed by only refreshing (or in your case observing) the things actually changed; in your case that may be only the items in the array that were added or removed. -- Gary L. Wade (Sent from my iPad) http://www.garywade.com/
> On Jan 25, 2016, at 1:10 AM, Markus Spoettl <ms_li...@shiftoption.com> wrote: > > Hi, > > I have a view controller with a table view that is bound to an array > containing around 1000-10000 model objects. The same view controller > registers itself as observer of all the objects' properties. These objects > are actually proxies for other model objects and are created by my view > controller (there is no outside reference to these objects). > > When the array changes, I remove all observers from these objects before > re-observing the new objects. > > Sometimes (on El Capitan) this removing of observers causes my app to freeze > and eat memory at an alarming rate. Sometimes this spirals completely out of > control until all memory is exhausted, sometimes it stops after a few > gigabytes of mystery allocations and my app continues. > > The bug doesn't surface all the time, only 30-50% of all tries. > > I have tried to wrap the observer removing code within an @autorelease {} > block, which helps a little. The problem is now harder to recreate, but it is > still there. > > This is on El Capitan using Xcode 6.4 built against the 10.10 SDK. > > Has anyone any idea how the removing of observers can cause this kind of > death spiral? > > Regards > Markus > -- > __________________________________________ > Markus Spoettl > _______________________________________________ _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com