tags:

views:

249

answers:

3

In new iOS4, we have fast app switching, and when we suspend the app, some data is still in memory and cost memory.

So, I just wonder if leaving data in memory will consume any battery life faster, comparing with using no memory? It will be good to know for programming the app to use less memory so that the whole iphone battery is better

I just want to know more about memory and battery than having any issue.

+2  A: 

As far as I am aware RAM consumes the same amount of power no matter how much of it is used. It might be another matter if 1 "stick" (or whatever you want to call the hardware division in the iPhone) is entirely unused.

Killer_X
Paraphrased: "RAM chips don't know about allocation", a bit like "hard disks don't know about file systems". It's unlikely that the phone will actually switch off a RAM chip if it sees that it's unused (perhaps because it can move the data to other chips); I've never heard of a computer which does this. It's also unlikely that DRAM refresh consumes a significant amount of power in any case, but note that some bit patterns (all zeroes or all ones?) may consume less power than others; so freeing RAM may still help if the system zeroes free pages.
tc.
+8  A: 

Theoretically, if your app has more data in memory, you might push another app's cached data out of memory, which could have some processing cost to restore if the user switches back. But I doubt it's measurable.

One good reason to reduce your memory usage when suspended is to reduce the chance that your app gets terminated to free up memory for the newly running app.

Douglas
Yes, it's best to minimize your application's memory footprint once it transitions to the background simply to allow more applications to hang around and not be terminated. Also, applications are terminated in descending order of memory size, so if your application is the largest one existing in the background, it will be killed first.
Brad Larson
yeah, I know about this.
vodkhang
+1  A: 

Another simple way is to test the iphone's battery usage by leaving it on with more memory content for longer time, new ios4 can display battery % that may help you notice the battery consumption over little longer period of time.

Akash Kava