Does allocating a large NSMutableArray cause low memory warnings?

Go To StackoverFlow.com

4

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?

2012-04-04 17:56
by Mausimo


3

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.

2012-04-04 18:00
by lxt
Not technically true. I have seen some applications (CHAOS, the game) for example that tell you certain things cannot be done if you do not have 15 MB of RAM free, so I'm not sure if that's being done via a malloc check or some system call, but It for sure is possible - Richard J. Ross III 2012-04-04 18:05
Technically you can get the memory available using 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
If i am using the allocation instrument and no new allocations are concurring, however every couple minutes I see a low memory warning, would this be because of the allocations I have done or possibly other applications - Mausimo 2012-04-04 19:13
Ads