Assumption: I am working on an iPhone project using Cocos2d 2.0 with ARC (and use Instruments of XCode 4.5.2).
Short question: Why resident memory is much higher than live bytes?
I say this because:
using instruments: I do get low memory warnings and I run my Allocation tool and see on avarage 3/5 MB of live bytes. Then I get a peak (18MB) and then back to 3/5MB. The problem is that, whenever I keep going back and forwards from one scene to the other I do get low memory warnings.
Using resident memory console print
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
[self report_memory];
[[CCDirector sharedDirector] purgeCachedData];
}
-(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 ) {
NSLog(@"Memory in use (in bytes): %u", info.resident_size);
} else {
NSLog(@"Error with task_info(): %s", mach_error_string(kerr));
}
}
I do get memory warnings and the prints are 48MB the first time, then 48MB again and then 66MB and then.. crash!
So I wonder, why do people say that I should worry only about Live Bytes?
In other words, assuming my App is the only one running (all the other ones are killed) can I say that having very low live bytes (ranging from 4MB to 20MB) does NOT imply that I will NOT receive low memory warnings?