Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone dev - why is it using 8MB?

Even when I just use the Window-based application template, which does literally nothing, instruments (activity monitor) says my application's process is using 8.14MB of Real Memory! Even with this method:

void report_memory(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);
    if( kerr == KERN_SUCCESS ) {
        NSLog(@"Memory in use (in bytes): %u", info.resident_size);
    } else {
        NSLog(@"Error with task_info(): %s", mach_error_string(kerr));
    }
}

Its still ~8.14 MB! So it seems that instruments is right, but why would a UIWindow take up that much memory??

like image 482
mk12 Avatar asked Nov 05 '22 19:11

mk12


1 Answers

My guess would be that it's the Objective-C runtime libraries that are taking up all that space, rather than your UIWindow itself. However, all applications use a copy of these libraries, the iPhone OS may be smart enough to share that memory among all of the applications that are running (although of course, only system apps are allowed to run in the background).

like image 95
David Avatar answered Nov 14 '22 20:11

David