0

I would like to know total RAM used by my application with code.

I have tried the following :

vm_statistics_data_t vmStats;
    mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT;
    kern_return_t kernReturn = host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmStats, &infoCount);
    if(kernReturn == KERN_SUCCESS) {
        printf("\nwire_count:%f",(vmStats.wire_count/1024.0));
        printf("\nactive_count:%f",(vmStats.active_count/1024.0));
        printf("\nfree_count:%f",(vmStats.free_count/1024.0));
        printf("\ninactive_count:%f",(vmStats.inactive_count/1024.0));
    }

It shows to me :

wire_count:256.197266

active_count:951.602539

free_count:98.450195

inactive_count:739.317383

But in the instruments, XCode shows me 9,2mb used by my application !!!

What's wrong here ?

Thanks

Caleb
  • 124,013
  • 19
  • 183
  • 272
  • Should you be using task_info? Could be a duplicate of [this question](http://stackoverflow.com/questions/5182924/where-is-my-ipad-runtime-memory-going) – Brian Walker May 29 '14 at 14:01
  • I have tried it, it shows me 10.2mb, but in the other side, XCode is showing in instruments 12,1mb. Any Ideas ? – user3545664 May 29 '14 at 15:44

0 Answers0