I made a tweak that shows free ram inside hooked SpringBoard method. I am using this code:
mach_port_t host_port;
mach_msg_type_number_t host_size;
vm_size_t pagesize;
host_port = mach_host_self();
host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
host_page_size(host_port, &pagesize);
vm_statistics_data_t vm_stat;
if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS){
ram = @"N/A";
}else{
natural_t bytes = (vm_stat.free_count * pagesize);
}
On devices prior 5s and Air it works fine. But 64bit device users reported that they getting amount of free ram larger than max amount of RAM on device. I made command-line utility with the same code and asked to run it as root from terminal, and the command-line utility showed correct values. I checked why it is happening and found out that inside SpringBoard on 64bit devices host_page_size(host_port, &pagesize);
returns pagesize = 16384 that is actually 4 times bigger than it shows in command-line utility. Again, it affects only 64 bit devices, on other devices it shows pagesize = 4096 (correct value) no matter where. It can be fixed with hardcoded pagesize = 4096 but I want to know why this is happening, maybe I am missing something important.