Re: Coding with VM limitation on the iPhone?
Re: Coding with VM limitation on the iPhone?
- Subject: Re: Coding with VM limitation on the iPhone?
- From: David Duncan <email@hidden>
- Date: Wed, 19 Aug 2009 11:04:00 -0700
On Aug 18, 2009, at 4:53 PM, Jonathon Kuo wrote:
Hmm, that's kind of a harsh environment... The notification
mechanism is great for the purpose of controlling bloat, but doesn't
tell you how much VM you have to play with at the outset. I suppose
all I can do is *try* to alloc() and if it fails, well, then what?
It sounds like it's mostly out of my control if whatever else is
running has already consumed VM. Gotta rethink this entire thing.
A medium to large malloc() is likely to succeed, even though using all
of the memory granted by that allocation is likely to fail. The most
significant difference between Mac OS X's virtual memory system and
iPhone OSes virtual memory system is that Mac OS X uses a page file,
and iPhone OS uses memory warnings.
If you have a lot of read-only data, one valid technique is to use
memory mapping to load load the data. iPhone OS, just like Mac OS X,
will create a memory region that is marked as backed by the memory
mapped file, and will properly handle pages from that file and throw
things away if memory is tight (before memory warnings). You can do
this with read-write data too, you just have no control over when data
is written (and writing to flash can be fairly costly).
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
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