Note that there are some explanatory texts on larger screens.

plurals
  1. POTotal RAM in iPhone
    primarykey
    data
    text
    <p>I want to know the <strong>Total</strong> RAM available in my iPhone. For this I've used the following code.</p> <p><strong>Note: Please do not interpret the question as to retrieve RAM statistics such as Wired, Inactive, Active and Free.</strong></p> <pre><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, &amp;pagesize); vm_statistics_data_t vm_stat; if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&amp;vm_stat, &amp;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; </code></pre> <p>Here are the results:</p> <ul> <li><strong>Simulator</strong>: total memory = 2045 (my PC contains 2GB RAM). Seems correct.</li> <li><strong>Device (iPhone 4)</strong>: total memory = 390 (<a href="https://stackoverflow.com/a/371117/864850">should be 512</a>). Incorrect.</li> <li><strong>Device (iPhone 3GS)</strong>: total memory = 84 (<a href="https://stackoverflow.com/a/371117/864850">should be 256</a>). Incorrect.</li> </ul> <p>Please let me know if this is the correct way to calculate the <strong>TOTAL</strong> RAM of an iDevice?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload