I think this used to be true more than it is now. Memory has been relatively expensive in cloud environments for a while (often 2x the price of an ec2 node for an equivalent with 2x RAM) and DRAM shortages aren't helping.
For the most part yeah but does depend on scale. For Java there are lower cost migration pathways like native compilation anyway if that does become your concern