Removing Observers eats up memory
Removing Observers eats up memory
- Subject: Removing Observers eats up memory
- From: Markus Spoettl <email@hidden>
- Date: Mon, 25 Jan 2016 10:10:38 +0100
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 (email@hidden)
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:
This email sent to email@hidden