I implemented an NSMutableArray in my app which has approximately 12,000 strings in it. In the allocations instrument it takes roughly 1000 KB and causes my total allocations to be 2200 KB.
Will using a massive array like this cause low memory warnings?
I have noticed low memory warning in the allocations instrument. Is there a way to see the total used/available memory of the device?
There's no way to view the 'available' memory, although Instruments will happily show you how much your app is consuming. This is for a number of reasons: even if it did show you how much memory was 'available' it wouldn't be very useful because it varies considerably in the field depending on what's in the background, whether you're listening to music, on a call, etc.
It's because of this problem that you have memory warnings: there are several levels, and they provide your app with opportunities to free up memory and avoid being terminated.
However, the 2200 KB you're talking about it not really that much in the grand scheme of things (if it helps you visualize these things, a 1024x768 image takes up more memory than that). So I wouldn't worry too much: that said, it's always beneficial to have your app respond to memory warnings by freeing up objects you don't need, if you can.
mach
- there is no real point, and there's no SDK method for it. The reason there's no real point is available physical memory doesn't equal the total available for allocation. Apps that require reboots to work or don't run if you don't have 'enough memory' are giving users awful experiences (and breaking the store guidelines as well). Much better just to rely on memory warnings alone and manage memory responsibly. Checking available physical memory is a bit like using retainCount
on an object: horribly misleading - lxt 2012-04-04 18:09
malloc
check or some system call, but It for sure is possible - Richard J. Ross III 2012-04-04 18:05