I am conducting a study on energy consumption, and I wonder if maintaining the instance of a variable entails a computational (and therefore energetic) cost over time, beyond the consumption of memory and the cost of creating the own instance.
I am conducting a study on energy consumption, and I wonder if maintaining the instance of a variable entails a computational (and therefore energetic) cost over time, beyond the consumption of memory and the cost of creating the own instance.
It is extremely difficult to estimate the computational cost of an instance of a class in Java, but neither can it be said to be zero even if that instance is not doing anything.
Initially, the JVM has a garbage collection mechanism whose operation depends on the implementation of the JVM that is being used and even the Java version. The truth is that garbage collection does have a computational cost and this is greater the more instances managed by a given program (even though those instances do nothing). So each of them contributes something, even a little, but their contribution is not zero.
From there to estimate the computational cost with which each instance contributes there is a very long way, it would be extremely complicated.
The instance will not have cost if it is not performing a task. Like the execution of one of your methods or a thread. The only cost that it would have is from memory, but it is very little (it depends on the data that it stores), with an instance it is not noticed.