I’m developing an app for the App Store, and having strange issues with memory management.
I am using ARC.
When testing my app on an unjailbroken iPod touch 4G 6.0.1 connected to Instruments, everything seems to go fine – my app uses less than 5mb of memory all the time and there are no leaks. However, after long usage, despite still being monitored in instruments as < 5Mb, i begin getting memory warnings and finally am killed by the OS. I do not have any open apps in the background, so i am assuming that my app is leaking memory instrumants cannot track. How can this be?
Further, i begun using a function to track memory usage, specyfically:
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 ) {
return info.resident_size/1024.0/1024.0;
} else {
return -1.0;
}
and it seems to report memory usage in range that could be expected by my app’s behaviour (60-70Mb). I do measurements simultaneously in Instruments and it still shows ~3-4Mb. What is going on here?
The Allocations instrument only track Heap memories, it’s just a small part of memory usage to the whole runnning application.
Take a look at the VM Tracker instrument, that is the whole virtual memory usage statistics, and maybe you can find the problem.