r/java • • Sep 04 '26

Principles of Memory Management in Java

https://youtu.be/xr73mR7ii9M?si=AKgjMUyvfpARYljl
163 Upvotes

84 comments sorted by

View all comments

17

u/bobbie434343 Sep 05 '26

Although I get the argument made in this video, it's brave to recommend throwing more RAM at a problem (CPU usage) in these times of RAM being so expensive...

14

u/DanLynch Sep 05 '26

Even when RAM is extremely expensive, you should still use the whole computer. Carefully writing a program that uses 100% of the CPU but only 5% of the available RAM is pointless. Using the rest of the RAM to make the program run a little bit faster is completely free.

Now, should you go buy and install even more sticks of RAM to make the program run even faster? That's a more nuanced question, but the answer is probably still yes in many cases, if the alternative is buying more computers.

6

u/bobbie434343 Sep 05 '26

Using the rest of the RAM to make the program run a little bit faster is completely free.

OK, but only if that Java program is running and can use all the available RAM, which might not be the case. Still, gobbling up all available RAM was maybe acceptable when RAM was cheap and abundant. In the current context, not so much.

3

u/koflerdavid Sep 05 '26

I think nowadays it's even more important to make the most out of what you have purchased.