I'm writing an application that needs to hold around forty 44 kb JPEGs in memory at once. I've heard that applications can use around 22 megabytes before triggering a low memory warning, so I'm pretty sure it should be able to do this. However, once I pass around a megabyte loaded, these messages start popping up in the console:
Mon Jun 8 16:37:19 unknown configd[21] : kernel memory event (90), free: 374, active: 1736, inactive: 959, purgeable: 0, wired: 6260 Mon Jun 8 16:37:20 unknown configd[21] : kernel memory event (95), free: 363, active: 876, inactive: 492, purgeable: 0, wired: 6241 Mon Jun 8 16:37:20 unknown SpringBoard[22] : Memory level is critical (5%). No apps to kill. Will kill SpringBoard Mon Jun 8 16:37:24 unknown SpringBoard[22] : Jetsaming SpringBoard...
Then it dumps me back to the home screen.
Here's the code I'm using to load the images:
#define NUM_IMAGES 40
@interface MyClass : NSObject {
UIImageView* imageView;
UIImage* loadedImages[NUM_IMAGES];
}
- (void)initImages;
@property (nonatomic, retain) IBOutlet UIImageView* imageView;
@end
@implementation MyClass
@synthesize imageView;
- (void)initImages {
int i;
for (i = 0; i < NUM_IMAGES; i++) {
loadedImages[i] = [UIImage imageNamed:[NSString stringWithFormat:IMAGE_FORMAT, i+1]];
}
imageView.image = loadedImages[0];
}
@end
Is there something I'm doing wrong here? Can iPhone applications really only use a megabyte of memory?