Low memory warnings not fired and app quits


#1

My Homepwner App quits after about 6 added items and the low memory warning seems to never get fired, so the cache from the image store is not cleared.
I debugged this with instruments and the used memory rises, like expected, with every item added - later I see the memory warning in the Instruments App, but it doesn’t get fired in BNRImageStore. App just quits.

I have this in mit BNRImageStore init method:

NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(clearCache:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];

And is it actually wise to fill the ImageStore to the point we get the low memory warning?
Should’t it be cleared much sooner?


#2

I think I found the answer myself:
On my iPhone 4S, photos are quite huge when uncompressed, like 30MB.
So when the third image gets put into RAM, it grows so quickly, that the App has no time to receive the notification.
(Because it is blocking the main thread?)
So waiting for a memory warning and reacting is not the proper solution, it has to be dealt with sooner.
I am using scaled down versions of images in the App, keeping the original files on disk but out of memory from now on.


#3

Same problem here, but I don’t want to reduce the size of the images. Why the low memory warning mechanism isn’t working?