4

There are memory warning level 1 and level 2 for iOS app. The question is for all iPad devices (from iPad 1 to iPad 4, mini ) , what is the responding threshold value to send out the warnings. For instance, for iPad1, is that 100 MB ?

Thanks


I also used to print out memory used when received memory warning.

#import "mach/mach.h"
-(void) report_memory {

    struct task_basic_info info;
    mach_msg_type_number_t size = sizeof(info);
    kern_return_t kerr = task_info(mach_task_self(),
                                   TASK_BASIC_INFO,
                                   (task_info_t)&info,
                                   &size);
    if( kerr == KERN_SUCCESS ) {
        DLog(@"Memory in use (in MB ): %u", info.resident_size/1024/1024);
    } else {
        DLog(@"Error with task_info(): %s", mach_error_string(kerr));
    }
}
casperOne
  • 73,706
  • 19
  • 184
  • 253
Forrest
  • 122,703
  • 20
  • 73
  • 107
  • 1
    Does it matter? If you see a level 1 memory warning, your app has very little time in which to clean up its act before a level 2 gets issued and your app gets killed off. – Michael Dautermann Mar 20 '13 at 08:21
  • If you products need support all different devices, and you will have serious memory issue, for example, always pop out the memory warning, and your boss is kicking your ass behind, how do you think ? The instrument can give you some idea how many real memory usage, and we need think about optimization solution especially for iPad1. Yes, it matters. – Forrest Mar 20 '13 at 08:29

2 Answers2

5

I don't think it is officially documented by Apple, mainly because it may change between iOS versions, but these are the figures stated in the "Learn iPhone and iPad cocos2d Game Development" book:

+-----------------------------------------------------------------+  
| Installed Memory |  Available Memory | Memory Warning Threshold |
+-----------------------------------------------------------------+  
| 128 MB           |  35-40 MB         |  20-25 MB                | 
| 256 MB           |  120-150 MB       |  80-90 MB                | 
| 512 MB           |  340-370 MB       |  260-300 MB (estimated)  |
+-----------------------------------------------------------------+
Daniel Martín
  • 7,815
  • 1
  • 29
  • 34
  • I assume these are for iOS 6 - does anyone have updated data for iOS 7? Thanks for your help. – Colen Dec 17 '13 at 18:27
3

From practice and memory... iPad 1 will trigger a level 1 at around 16Mb and probably go to level 2 at about 32mb. iPad 2/3/mini seem to be OK up to about 50Mb to 64Mb. iPad 4 I've not really got conclusive results but from the specs i'd anticipate up to about 100-128Mb before things start to complain.

This is what I've observed in instruments at least during testing. I've taken to running a macro to detect device type and gracefully fall back to support older devices by disabling quartz drawn items, heavy images etc...

Again these aren;t hard figures from any specs just my findings from testing.

Here's a class method I use in the app delegate to detect iPad 1 for example...

+ (BOOL)isiPad1 {
  struct utsname platform;
  int rc = uname(&platform);
  if(rc == -1) return NO;
  return !strcmp("iPad1,1", platform.machine);
}
Cocoadelica
  • 3,006
  • 27
  • 30