Re: Releasing resources when cells are returned to the queue?
Re: Releasing resources when cells are returned to the queue?
- Subject: Re: Releasing resources when cells are returned to the queue?
- From: Quincey Morris <email@hidden>
- Date: Tue, 09 Jun 2015 21:34:48 +0000
On Jun 9, 2015, at 14:23 , Rick Mann <email@hidden> wrote:
>
> I'd like to release resources in my collection view cells when they are returned to the reuse queue. But I can't see a way to do this. There is a call on the cell when they are popped from the queue and about to be reused, but none when they're put on the queue in the first place.
The 10.11 AppKit release notes say that the table cell’s “objectValue” is now zeroed when cells are queued for re-use, so I guess that implies there’s currently no way to do it.
> We're running into memory problems, and these cells continue to hang on to stuff that I'd like to release when the memory warning happens. Unfortunately, there's no easy way to get at already-instantiated cells that are NOT on screen (as far as I can tell).
You could keep a collection of weak references (that is, a NSMapTable with weak values) to cells when they are dequeued, and run through the surviving cells on a memory warning, selectively unloading stuff from memory.
IIRC, you can also opt out of the table view’s queuing mechanism completely, and manage all the cells yourself.
_______________________________________________
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