NoobDev4iPhone
NoobDev4iPhone

Reputation: 5739

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.

Upvotes: 7

Views: 6190

Answers (3)

Ankit Srivastava
Ankit Srivastava

Reputation: 12405

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.

Upvotes: 1

Abhi Beckert
Abhi Beckert

Reputation: 33379

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.

Upvotes: 2

DarkDust
DarkDust

Reputation: 92394

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.

Upvotes: 11

Related Questions