Mobile safari will dump memory & crash at about 10MB

While designing an application heavy on image usage I ran into issues with Mobile Safari simply crashing and dumping all memory. At first, I did not understand what caused this behavior since I was doing many different things in my application.

This seemed to come out of nowhere. I would mostly get these bug reports when the app was used in production, but even then this was not an issue for the majority.

Finally, it became clear to me that this would only occur after a certain number of images had been loaded into memory. This being far more than I usually felt I had to test with.

It would appear that Mobile Safari has a much stricter limit on resource usage than normal desktop browsers. In our scenario when Mobile Safari had loaded about 10MB of image data into memory, it would simply crash and dump all memory. Since this behavior can happen in other situations it was not the best indicator when trying to debug it. It took some time but once we knew what the problem was, the solution was simply to implement a protocol for unloading images again when needed.

For the exact rules regarding mobile safaris resource limitation that answer is more complex than 10MB being the limit. It depends on device memory and the image compression algorithm being used. You can find the documentation and read for yourself here.

Comments

  1. Care to share your solution for unloading images?

    • Jacob T. Nielsen says:

      Unloading images was simply removing them from the DOM. The solution I talk about was limiting the number of images to a maximum of 6 (we only ever needed 6 images to be active at a time. 2 visible and 4 preloaded).

Leave a Reply to Jacob T. Nielsen Cancel reply

*