2

I'm maintaining a linux server which manages 100 TPS API traffics. Initially, it had only 8GB memory. We recently doubled the memory and doubled the JVM memory consumption upper limit as well. Still the free memory is very low.

free -m
              total        used        free      shared  buff/cache   available
Mem:          15885        9909         156          15        5819        5584
Swap:         18431         127       18304

As you can see, free memory is 156MB. When the cache memory is cleared, free memory increases. But still it drops down to same level within few hours. Is this the normal behavior or do I need to increase memory again?

10

It's a normal behaviour. Any unused memory will be used for cache, to improve overall performances. That memory will be freed automatically if it's needed for something else. You don't have to ever drop caches except to check this specific behaviour and show it to somebody. If the memory were to be kept as free, then your disk I/O activity would likely go up and your application would probably become slower.

Also I believe java naturally uses more memory when it sees more memory available, and requires a lot of parameters to prevent it from doing this.

If some monitoring tool alarms on memory usage because of this, you should correct the monitoring tool to give a correct report of the actual memory available (eg: here free tells you 5584mb available beside the 156mb free).

As a side note, the fact that 157mb of swap are in use isn't a problem as long as it's not swapping in and swapping out (this can be checked with vmstat). That means 157mb more memory was made available for real activity. That's still something to keep an eye on.

3

The Linux kernel uses as much memory as is needed / possible as buffer or cache memory. This speeds up the system and is totally intended. The number you are really looking for is in the column titled 'available'. If more memory is needed for applications, the OS will free some of the cache memory to use for this application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.