Ubuntu 21.04 using huge amounts of RAM just after sign-in

For some reason Ubuntu is using a lot of RAM on my PC. I ran the free -h command just after logging in and before opening any application. This is what I got:

              total        used        free      shared  buff/cache   available
Mem:           31Gi        19Gi       9.7Gi       124Mi       2.5Gi        11Gi
Swap:         2.0Gi          0B       2.0Gi

I installed 21.04 a few months back. I cannot say that I checked the memory usage before, and I also don't see any lagging or evident performance issues, but this is pretty weird.

What could be happening?


Turns out that there was an Elasticsearch process (not displayed by System Monitor) which was consuming over half of my RAM.

This command ps -o pid,user,%mem,command ax | sort -b -k3 -r showed: 3051 elastic+ 54.2 /usr/share/elasticsearch/jdk/bin/java... where that 54.2 is the percentage of total RAM used by the process.

This post helped me decrease the total allocated memory for Elasticsearch