Available memory for iPhone OS app -


is there function or constant defining amount of available memory app in iphone os?

i'm looking device-independent way (ipod touch, iphone, ipad) know how memory app has left.

this function return available memory in bytes:

#import <mach/mach.h>  #import <mach/mach_host.h>  natural_t  freememory(void) {     mach_port_t           host_port = mach_host_self();     mach_msg_type_number_t   host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);     vm_size_t               pagesize;     vm_statistics_data_t     vm_stat;      host_page_size(host_port, &pagesize);      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_used = (vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count) * pagesize;     natural_t   mem_free = vm_stat.free_count * pagesize;     natural_t   mem_total = mem_used + mem_free;      return mem_free; } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -