Re: Deadlock during NSCache flush
Re: Deadlock during NSCache flush
- Subject: Re: Deadlock during NSCache flush
- From: Ken Thomases <email@hidden>
- Date: Mon, 21 Oct 2013 14:28:05 -0500
On Oct 21, 2013, at 2:11 PM, Jens Alfke wrote:
> Specifically, there is a “database” object that has a strong reference to an NSCache which maps to various ‘document’ objects (indexed by key.) The document objects have strong references back to the database.
>
> In the situation that hangs, there is a database with one document, neither of which have any external strong references to them. (They probably used to at one point, but the app stopped using that database.) That’s fine, it’s not a reference cycle because the NSCache will get cleaned up.
Seems like a cycle to me. You can't rely on NSCache spontaneously evicting objects as the means for eliminating the cycle. It might never do so.
In any case, it seems like the database owns the documents in the cache. If nothing external has a strong reference to it – if "the app stopped using that database" – why should it keep existing even if the cache would clean it up "eventually"?
Have the documents hold weak references to the database.
Regards,
Ken
_______________________________________________
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