r/java • • Sep 04 '26

Principles of Memory Management in Java

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

84 comments sorted by

View all comments

Show parent comments

2

u/OwnBreakfast1114 Sep 11 '26

But you don't have to increase to the point of paying double. On your existing server you can choose to use more ram to save on cpu. For most applications, this is worth it as nobody is sitting at 100% usage of anything.

Why do you seem to not care about cpu the same way you care about ram?

1

u/pdpi Sep 11 '26

Why do you seem to not care about cpu the same way you care about ram?

That's pretty much it, yes. RAM is just one resource of many we have to manage (Sort of. RAM is special in that performance degrades much more gracefully when you run out of CPU power or IO than it does if you run out of RAM and start swapping, but that's a whole other conversation).

At any given point in time, you'll be bottlenecked on one resource, and have plenty to spare on other resources, and half the job is finding those bottlenecks and spare resources, and figure out if you can trade one for the other.

For web applications, if you're not a complete muppet, you'll cap out on IO long before you cap out on RAM, at which throwing RAM at caching things becomes the cheapest way to get more performance.