Quiero saber Total RAM disponible en mi iPhone. Para esto, he usado el siguiente código.RAM total en iPhone
Nota: No interprete la pregunta como para recuperar las estadísticas de RAM como por cable, inactivo, activo y gratuito.
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) {
NSLog(@"Failed to fetch vm statistics");
return;
}
/* Stats in bytes */
self.wired = vm_stat.wire_count * pagesize/(1024 * 1024);
self.active = vm_stat.active_count * pagesize/(1024 * 1024);
self.inactive = vm_stat.inactive_count * pagesize/(1024 * 1024);
self.free = vm_stat.free_count * pagesize/(1024 * 1024);
self.used = self.active + self.inactive + self.wired;
self.total = self.used + self.free;
Éstos son los resultados:
- Simulador: Memoria total = 2045 (mi PC contiene 2 GB de RAM). Parece correcto.
- Dispositivo (iPhone 4): memoria total = 390 (should be 512). Incorrecto.
- Dispositivo (iPhone 3GS): memoria total = 84 (should be 256). Incorrecto.
Por favor, hágamelo saber si esta es la forma correcta de calcular el TOTAL DE memoria RAM de un iDevice?
duplicado Posible de http://stackoverflow.com/questions/8032635/responding-to-ram-availability-in-ios/8072278#8072278 –