views:

25

answers:

2

I wrote an app compiled against ios 3 that would easily allocate up to 100 mb of memory for image processing purposes. However, when that same app was compiled against the ios 4 sdk, I found that it crashed when many apps were open in the background. When I kill the background apps, the application then runs fine. I reduced the memory usage to 70mb, and I still find that it crashes when many background apps are open.

Why are apps compiled against ios 3 are able to get more memory on phones running ios 4?? Is there something special you need to do to tell the ios 4 OS to give you more memory? Is there a way to cause background apps to be closed in order to allocate more memory for your app?

BTW, the app uses Core Graphics to some extent. Would that affect the apps ability to request memory?

A: 

Given your description, your app was pushing the memory allocation envelope on iOS 3.x, but goes too far in 4.x, likely because the newer operating system is using more memory.

The only solution is to use less memory. It really is that simple. You can't control how much memory the underlying OS will use to run processes. The only thing you can control is your app and how much memory you allocate so you don't crash.

Shaggy Frog
However, the app when compiled against ios 3 and run on a phone running ios 4 seems to be able to allocate more memory. How can the sdk version of the app affect how much memory it can allocate?
ConvexCoder
You might want to pose that question on the official Apple dev support forum as there's a slightly better chance that an Apple engineer will see it and respond than here. But I still think you're on the wrong approach. You might be able to get it to allocate all this memory on 4.0.2, but who's to say it won't fail on 4.1? Or 4.1.1? If you want to future-proof, you're going to have to cut back on your memory allocation as much as possible.
Shaggy Frog
A: 

It's unlikely that you "find that it crashes when many background apps are open". Almost certainly the system is terminating your app for using too much memory and ignoring any warnings to that effect. (I guess you could crash by trying to allocate more memory than the system has available, but that would have to be a very large allocation made in a large chunk).

Tell us more about how you're allocating this memory. Are you paying attention to low memory warnings?

Mike Abdullah