Re: Odd NSCache Eviction Behaviour
Re: Odd NSCache Eviction Behaviour
- Subject: Re: Odd NSCache Eviction Behaviour
- From: Dalmazio Brisinda <email@hidden>
- Date: Wed, 06 Apr 2011 10:12:31 +0700
On 2011-04-05, at 7:16 PM, Graham Cox wrote:
>
> On 05/04/2011, at 7:01 PM, Dalmazio Brisinda wrote:
>
>> Pity. NSCache looked so promising
>
>
> You could roll your own cache class that has the same interface but uses a LRU algorithm internally. Then if NSCache is updated it would be a drop-in replacement. The only drawback with it at present (which might be considered rather major) is that there's no straightforward way to hook your own cache objects into the runtime such that it would automatically cause eviction when memory pressure is tight. On iOS I believe there is a hook for responding to low memory, but on Mac OS there isn't, unfortunately. The best you can do is to set some sort of high water mark limit that evicts the LRU objects whenever the cache is accessed. Doing that is obviously pretty straightforward.
>
> --Graham
Thanks Graham. Your suggestion sounds like a good idea.
I'll begin experimenting with duplicating the NSCache API, and just use a high water mark limit for the time being.
I wonder if it's worthwhile to base this high-water mark on anything other than a static value? Like perhaps some physical resource-aware value?
Best,
Dalmazio
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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