Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why memory warnings with 4 MB utilization and 320 MB free?

I'm testing on an iPhone 4 running iOS 7.1 attached to Xcode 5.1.1. I don't understand why I am getting memory warnings and even crashes when instruments shows my app is only using a few megabytes and there is plenty of memory free (see attached). Any ideas?

Memory Utilization of App while Receiving Warnings

Update:

In instruments, as I suspected, I found no leaks, but the "Anonymous VM" size seems unduly large and filled with image data. Each table cell in my app displays a JPEG. Perhaps I should be pre-scaling these images and that is the cause of the large Anonymous VM size... More investigation to be done.

Instruments Allocations

like image 220
davecom Avatar asked Sep 29 '22 23:09

davecom


1 Answers

It turned out images displayed in UIImageViews in each and every table cell were being stored in memory at their full size, not the scaled size (size of the UIImageView). This only showed up in the "Anonymous VM" in Instruments (since iOS only stores references to your images in your application heap and the actual image caches are in system memory it seems), not in the basic memory usage displayed in Xcode. I resolved the issue by pre-scaling my images before putting them into the UIImageViews of the table view cells. There were no leaks.

like image 170
davecom Avatar answered Nov 02 '22 23:11

davecom