Why does mmap fail on iOS?

后端 未结 4 1791
醉话见心
醉话见心 2021-02-07 15:26

I\'m trying to use mmap to read and play audio files on iOS. It works fine for files up to about 400MB. But when I try a 500MB file, I get a ENOMEM error.

char *         


        
4条回答
  •  情深已故
    2021-02-07 15:33

    After further investigation and reading this excellent blog post by John Carmack, here are my conclusions:

    • 700MB is the limit for virtual memory on iOS (as of 2012, 32-bit iOS)
    • It may or may not be available in a single block; this depends on device state and app behaviour

    Therefore, to reliably mmap 700MB worth of file data it is necessary to break it into smaller chunks.

提交回复
热议问题