Memory mapping limitations on iOS

Hi all,

I’m currently playing with memory-mapped files on iOS 12.2. If I load a large file, say around 2 gb, and try to map it entirely, mmap fails with error ENOMEM (i.e. “No memory is available”).

I’m aware of virtual memory limitations on 32-bit systems, but I’m working with a 5th generation iPad which is 64-bit by nature. On top of that I’m pretty sure I’m building the app for arm64 - just double-checked it on XCode.

Can you confirm this behavior? Is there actually a limitation on how much virtual memory you can use on iOS or am I just missing something?

1 Like

Yes, there is a limit on iOS to how much virtual memory you can use. The system is quite limited compared to a desktop OS VM system. Only read-only pages can be paged out. Back in the day each process was limited to about 700 MB of VM, might be higher now, I haven’t done iOS stuff in a while.

2 Likes

@G-Mon the limit seems a bit higher now - around 2 GB according to my empirical tests, the same amount of physical memory. At least on my model.

I wonder how other DAWs like Cubasis or GarageBand handle big audio files: if mmaped, they would surely trigger the 2GB limit soon. I’m pretty sure you can create projects way larger than that…