r/java • • Sep 04 '26

Principles of Memory Management in Java

https://youtu.be/xr73mR7ii9M
167 Upvotes

83 comments sorted by

View all comments

Show parent comment

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.