Calling getters on an object vs. storing it as a local variable (memory footprint, performance)

I’d nearly always prefer the local variable solution. Memory footprint A single local variable costs 4 or 8 bytes. It’s a reference and there’s no recursion, so let’s ignore it. Performance If this is a simple getter, the JVM can memoize it itself, so there’s no difference. If it’s a expensive call which can’t be … Read more