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 (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