Re: iPhone resource cache - memory question
Re: iPhone resource cache - memory question
- Subject: Re: iPhone resource cache - memory question
- From: Jens Alfke <email@hidden>
- Date: Thu, 6 May 2010 11:12:48 -0700
On May 6, 2010, at 11:02 AM, David Duncan wrote:
For images I would use a cost estimate of width * height * 4 (this
is typically what the memory cost to decompress and display an
optimized PNG).
Agreed. There are CG APIs that let you render an image directly from
compressed file data without creating an intermediate pixmap, but they
obviously have lower performance.
For audio this is more difficult as it is unlikely that the entire
file will be loaded into memory, or even that a significant amount
of it will be loaded into memory unless it is playing (in which case
you do not want to unload it).
It depends on the API. In general, the higher level convenience APIs
aimed at playing simple alert sounds will load the entire waveform
into memory. (NSSound works this way on Mac; I'm not familiar enough
with the iPhone equivalents.) One way to tell is to use the API to
play a long audio file (like a 20-minute MP3 track) and see how much
memory the process allocates.
An intermediate level would be if the library loads the _compressed_
audio. This is a lot less memory usage. It may even memory-map the
file, which wouldn't affect your process's heap space at all. (I know
the iPhone doesn't have VM, but I'm pretty sure it at least supports
memory-mapping because that's pretty critical for loading code.)
—Jens_______________________________________________
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