Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone app uses 150 MB memory and still no low memory warning!

Tags:

iphone

ios4

I have a questionary application, navigation based which I create and push my tableviews eachtime from a nib. there is no leakage and in instruments live bytes seems around 2-3 MB.

I tested in real device (jailbroken IOS4 iPhone), when I go through deep in the navigation (around 200 page pushes) I can see that memory usage goes upto 150 MB! when I navigate back to root then they are all freed, but isnt this a weird behavior? (around 800 KB for each nib view and no big data or images in it)

The most weird thing is, I put some alerts to didreceivememorywarning and didunloadview methods, and yet didnt receive any memory alerts!

-Why I never get any memory warning and viewDidUnload even the app uses 150 MB and more of memory? -Application works but is this memory usage a problem for Apple store?

like image 780
Spring Avatar asked Dec 02 '22 01:12

Spring


2 Answers

Something Funky is going on. Try the following code to check the OS version of how much memory you app uses

-(void) report_memory {
    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));
    }


}

You will need to #import "mach/mach.h"

This will tell you how much memory the operating system has granted your app. So if what you are seeing is some weird Instruments behavior, this should shed some light.

like image 115
fsaint Avatar answered Dec 24 '22 19:12

fsaint


I just add self.view=nil in viewDidDisappear method, it works and I can recover back, much better now. tnx Felz for the help

like image 41
Spring Avatar answered Dec 24 '22 18:12

Spring