Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does memory use affect battery life?

How does memory allocation affect battery usage? Does holding lots of data in variables consume more power than performing many iterations of basic calculations?

P.S. I'm working on a scientific app for mac, and want to optimize it for battery consumption.

like image 846
NoobDev4iPhone Avatar asked Dec 12 '11 09:12

NoobDev4iPhone


3 Answers

The amount of data you hold in memory doesn't influence the battery life as the complete memory has to be refreshed all the time, whether you store something there or not (the memory controller doesn't know whether a part is "unused", AFAIK).

By contrast, calculations do require power. Especially if they might wake up the CPU from an idle or low power state.

like image 57
DarkDust Avatar answered Sep 20 '22 15:09

DarkDust


I believe RAM consumption is identical regardless of whether it's full or empty. However more physical RAM you have in the machine the more power it will consume.

On a mac, you will want to avoid hitting the hard drive, so try to make sure you don't read the disk very often and definitely don't consume so much RAM you start using virtual memory (or push other apps into virtual memory).

Most modern macs will also partially power down the CPU(s) when they aren't very busy, so reducing CPU usage will actually reduce power consumption.

like image 40
Abhi Beckert Avatar answered Sep 19 '22 15:09

Abhi Beckert


On the other hand when your app uses more memory it pushes other apps cache data out of the memory and the processing can have some battery cost if the user decides to switch from one to the other, but that i think will be negligible. 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.

like image 26
Ankit Srivastava Avatar answered Sep 20 '22 15:09

Ankit Srivastava