0

I have a VPS with ubuntu 18.04.4 with 2gb and 512mb swap. Working regularly with 600-800mb and 100mb swap and all is well.

2 weeks ago I updated the WAR (tomcat) and the memory jumped to 1.2gb and 400-500mb swap. At first I thought it's normal because I did change something that should consume more memory.

I needed to restart the server (for another reason). Only then I realized that the memory got down again to 600-800mb and 300mb swap and it was like that for some time. Meaning previously, something hogged the memory and it was released with the restart.

After 2 weeks with the same consumption, I updated the WAR and again I noticed that after the re-deployment, the memory jumped to 1.2gb with 400mb swap. This time I only restarted the tomcat service and the memory consumption got down to 600mb and 100mb swap.

htop shows that Java is the one that consumes the memory but how can I know what is it exactly that is hogging the memory after undeploy/deploy that only a service restart releases it?

Thanks

Amos
  • 141
  • 6

1 Answers1

0

https://www.linuxatemyram.com/

It is normal for the operating system to use all the memory available, even light use of swap space.

Do not make much of an effort to force it back below 50% utilized. That is just going to get used again. And unlikely to be something worry much about when utilization hovers at what sounds like a nice 60%. For example, any file system caches of either copy of the application file would be quickly reclaimed if needed for other memory.

Rather, watch for the application itself being slow. Set a target user response time or similar, and monitor how you meet the service target. User experience is much more important than what you think the memory utilization should be.

For OS memory metrics, on Linux watch the page in and out rates. A memory starved system will do a heavy page rate in, as it needs to move memory back in to work on. This makes for a just slow feeling system, as swap space is much slower than DRAM.

And obviously running completely out of memory is bad, OOM killer or maybe panic. But this happens much closer to 0 pages available. You have not shown evidence of severe memory pressure.

Java has its own memory tuning, between heap metric collection, tuning, and avoiding garbage collect pauses. That's a question for another time, perhaps after you study this application's heap patterns, and estimate how much memory budget you really have on this 2 GB instance.

John Mahowald
  • 30,009
  • 1
  • 17
  • 32
  • Thank you for a detailed explanation. My worry was about the unexplained memory consumption and not the fact it was consumed. It was as if something was not released correctly up until the restart of the service. It might have not slow things down but if something is hogging the memory when it shouldn't, I want to know about it. – Amos Jul 05 '20 at 12:46