On Jul 2, 2010, at 12:14 AM, Graham Cox wrote:

> I'd like to be able to do something a bit like it on 10.5. Is there a 
> notification or other callback I can use to get notified when the system is 
> running low on memory for my app, to give it an opportunity to discard stuff 
> before it starts paging memory out?

On a Modern OS™ it’s not easy to say when the system’s running low on memory, 
because there’s physical RAM, and there’s address space, and the pages in 
address space can be clean or dirty, or mapped from a file, and so forth. And 
all of that stuff is shareable between processes.

What NSCache does, I believe, is use the vm_allocate() system call to allocate 
address space that’s marked as being purgeable: its pages won’t get written to 
backing store, they just get thrown away. You have to make calls to lock and 
unlock purgeable memory so it won’t get thrown away while you’re using it.

There’s some info about vm_allocate here, although it doesn’t talk about the 
purgeable mode. IIRC, the header file does, though.
http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/MemoryAlloc.html

—Jens_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to