Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory warning threshold value for all iPad version

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));
    }
}
like image 772
Forrest Avatar asked Feb 17 '23 02:02

Forrest


2 Answers

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)  |
+-----------------------------------------------------------------+
like image 78
Daniel Martín Avatar answered Feb 19 '23 23:02

Daniel Martín


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);
}
like image 38
Cocoadelica Avatar answered Feb 20 '23 00:02

Cocoadelica