Hacker News new | ask | show | jobs
by clarry 3082 days ago
> If you have enough memory for your workload that you won't run out, swapping lets you use more memory for disk cache

Except that it doesn't happen in practice, on my systems anyway. If you have plenty of memory, you can keep all your programs in it and as much as the system wants to cache and still not run out.

The theory says that swap effectively buys you some memory to spend on more important things (than what the system chooses to page out). So does buying more memory.

> Unless by "won't run out" you mean "never have to throw away a disk cache page", which seems very unrealistic.

I have an instance of top running on my desktops & laptops all the time. I never see cache using up all of the memory.

                  total        used        free      shared  buff/cache   available
    Mem:           7848        1523        5827          53         497        6033
1 comments

Are you talking desktop workflows here? If this is a service, why are you paying for RAM that never gets used? Get a smaller instance.
> Are you talking desktop workflows here?

Yes [I explicitly spelled out desktops & laptops] but it's been true on my servers too.

> If this is a service, why are you paying for RAM that never gets used? Get a smaller instance.

Not all providers are so flexible. I may want a server with more CPU & traffic and some additional disk space. Going there gets me more RAM too. It turns out these services are constrained by the real hardware. If I'm getting a box with enough CPU for my needs, well they are not going to a shop to buy that special box for me, they use what they have and what they have comes with plenty of RAM too.