iphone - get free ram on iOS 9? -


i trying free ram on ios device code below gives me 34mb on ios 9, iphone 5s device when there 1 app running using 98mb ram. there bug in below code ?

natural_t get_free_memory () { 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 fetch vm statistics"); } natural_t mem_free = vm_stat.free_count * pagesize; return mem_free; } 

ios unix system (derived bsd), features both multi-tasking , complex memory management.

there little chance there's single process running on phone. if no apps running (i.e. actively terminated other apps "sliding them up" in task switcher), there's gazillion daemons still running perform various tasks.

beyond that, there's memory used kernel, , memory used cache through various paths. free memory not indicative of available memory @ all, system tries use memory possible caches , other similar purposes.

i have freebsd box (freebsd being, right after mac os x, closest os ios) 64 gb of ram doing nothing, , reports 848 mb free... 56 gb "inactive" memory, on 1 gb "cache" , 1.5gb "buffers". of memory available, it's not considered "free" os has mappings pages (but release them if needed).


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -