How can you effectively free the memory of a modal viewcontroller with ARC ?
I saw a few topics on the subject, but I actually didn't find any answer to what seems like a common problem when dealing with modal view controllers.
I made a sample application in which viewcontroller1 presents modally viewcontroller2. When I dismiss viewcontroller2 (from viewcontroller1), the memory is not released ! :( (see memory log below)
Strange : there are no strong references of viewcontroller2 in viewcontroller1, and viewcontroller2 dealloc is indeed called ...
The viewcontrollers are presented/dismissed using presentModalViewController/dismissModalViewControllerAnimated
See my memory Usage :
ViewController1 Displayed : 7.41 Mb Usage
--ACTION : Show ViewController2--
ViewController2 Displayed : 8.11 Mb Usage
--ACTION : Dismiss ViewController2--
ViewController1 Displayed : 8.06 Mb Usage
--ACTION : Show ViewController2--
ViewController2 Displayed : 8.11 Mb Usage
--ACTION : Dismiss ViewController2--
ViewController1 Displayed : 8.06 Mb Usage
--ACTION : Show ViewController2--
ViewController2 Displayed : 8.11 Mb Usage
--ACTION :Dismiss ViewController2--
ViewController1 Displayed : 8.06 Mb Usage
Thanks
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); double sizeInMegaBytes = (double)info.resident_size / 1000000;
– Dev Oue