Reputation: 949
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?
Upvotes: 1
Views: 185
Reputation: 1748
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.
Upvotes: 1
Reputation: 162712
Instruments is likely tracking heap allocations and not total address space consumption. If you have an app that is causing a lot of files to be memory mapped, that can lead to a situation where the amount of heap allocations (malloc, etc) are low, but the app's system memory consumption is high.
Without knowing more about your app, it isn't possible to really conjecture beyond the above.
Upvotes: 4