According to what I've read so far, real/resident bytes indicates the number of bytes allocated to the app including bytes that the app is no longer using but hasn't been reclaimed by the OS. And live/dirty bytes is the bytes the the app is actually using and the OS can't reclaim. I think that the number shown in XCode Debug navigator is Live Bytes.
I'm interested in getting this number programmatically (for our own statistics/analytics), but the code I found can only give the value of resident bytes, which is larger than the value that Xcode is showing on some devices (almost twice is large), actually on the same devices but different iOS versions. (on iOS 9 it gives a value almost twice as large but on iOS 11 it gives almost the same value as Xcode).
The code I am using is this:
struct mach_task_basic_info info;
mach_msg_type_number_t size = MACH_TASK_BASIC_INFO_COUNT;
kern_return_t kerr = task_info(mach_task_self(),
MACH_TASK_BASIC_INFO,
(task_info_t)&info,
&size);
if( kerr == KERN_SUCCESS ) {
NSLog(@"Memory in use (in bytes): %u", info.resident_size);
return info.resident_size;
} else {
NSLog(@"Error with task_info(): %s", mach_error_string(kerr));
}
Is there some code to get the live bytes value like Xcode shows?