How to measure SDK storage in an iOS app

I have tried to measure the amount of memory using various methods - and each method returns a different value.

The first way looked at low caliber in Xcode during application launch. It shows 20.9 MB of usage: enter image description here

Second way to use this code (it shows 38-39MB usage):

vm_size_t usedMemory(void) {
    struct task_basic_info info;
    mach_msg_type_number_t size = sizeof(info);
    kern_return_t kerr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &size);
    return (kerr == KERN_SUCCESS) ? info.resident_size : 0; // size in bytes
}

vm_size_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);
    (void) host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size);
    return vm_stat.free_count * pagesize;
}

void logMemUsage(void) {
    // compute memory usage and log if different by >= 100k
    static long prevMemUsage = 0;
    long curMemUsage = usedMemory();
    long memUsageDiff = curMemUsage - prevMemUsage;

//    if (memUsageDiff > 100000 || memUsageDiff < -100000) {
        prevMemUsage = curMemUsage;
        NSLog(@"Memory used %7.1f (%+5.0f), free %7.1f kb", curMemUsage/1000.0f, memUsageDiff/1000.0f, freeMemory()/1000.0f);
//    }
}

      

The third way is using tools that show roughly 19-20 MB of usage

enter image description here

The bottom line is what I need to figure out how to measure the SDK memory size. (Before adding SDK and after adding SDK or "Blackbox" SDK measurements)

How and why do the results differ from each other?

I

+3
performance ios memory sdk memory-footprint


source to share


No one has answered this question yet

Check out similar questions:

3295
Why is the Android emulator so slow? How can we speed up the development of an Android emulator?
3044
Making a memory leak with Java
2302
How does database indexing work?
1248
How can you speed up Eclipse?
1116
Android SDK installation not finding JDK
977
Measure time elapsed in Python
958
How do I change the name of an iOS app?
772
How can I find out the memory usage of my application in Android?
680
How to connect to apps in the app store
672
How do you measure the actual memory usage of an application or process?



All Articles
Loading...
X
Show
Funny
Dev
Pics