System Resources question from a new Linux user

Hi everyone. I’m new to this community as well as Linux in general. I want to start off by complimenting this great website design, It is really helpful and intuitive. Thanks for the hard work here.

I distro-hopped for a long time while I was learning a lot. I really love Debian and want to migrate there eventually but I just have headaches and spend too much time in it trying to make things work like my WIFI adapters, network configuration or certain drivers. This is because Im so new to this sort of computing (Windows 7 gaming junkie going through rehab). I finally settled on Ubuntu MATE 18.04, which I’m loving so far.

My question is regarding memory and CPU usage and how it differs in 3 different areas. I had a system monitor panel display that I ended up removing because of this issue. The standard System Monitor app displays a higher CPU and RAM usage than the panel display, as well as the output of htop through the terminal. When I first boot I’m using about the same amout of RAM in all 3 references (its about 800MB-1.1GB / 8GB). As I work or browse the web or play a game and then close everything, the idle RAM usage seems to get higher and higher until I have to reboot because in the System Monitor I’m using over 30% of the RAM while idling. I dont think I have to reboot, because I dont really notice bad performance, and htop displays about 2.7GB at most when idling after I’ve ran a lot of applications.

Upon reboot it will go down again. I don’t really want to reboot because this machine is also a SAMBA server for my kids to share files with me and I wouldn’t want to interrupt anything they may be uploading or retrieving from me. **Htop always displays a much lower CPU and RAM usage than the system monitor application does. **
Which memory monitor do I trust or which one is correct?

here is my output of ~$ sudo lshw -c memory :
*-firmware
description: BIOS
vendor: American Megatrends Inc.
physical id: 0
version: 3.90
date: 07/05/2018
size: 64KiB
capacity: 8128KiB
capabilities: pci upgrade shadowing cdboot bootselect socketedrom edd int13floppy1200 int13floppy720 int13floppy2880 int5printscreen int9keyboard int14serial int17printer acpi usb biosbootspecification uefi
*-memory
description: System Memory
physical id: 3c
slot: System board or motherboard
size: 8GiB
*-bank:0
description: DIMM DDR4 Synchronous Unbuffered (Unregistered) 2400 MHz (0.4 ns)
product: 2400 C16 Series
vendor: 8502
physical id: 0
serial: 00000000
slot: ChannelA-DIMM0
size: 4GiB
width: 64 bits
clock: 2400MHz (0.4ns)
*-bank:1
description: [empty]
physical id: 1
slot: ChannelA-DIMM1
*-bank:2
description: DIMM DDR4 Synchronous Unbuffered (Unregistered) 2400 MHz (0.4 ns)
product: 2400 C16 Series
vendor: 8502
physical id: 2
serial: 00000000
slot: ChannelB-DIMM0
size: 4GiB
width: 64 bits
clock: 2400MHz (0.4ns)
*-bank:3
description: [empty]
physical id: 3
slot: ChannelB-DIMM1
*-cache:0
description: L1 cache
physical id: 42
slot: L1 Cache
size: 128KiB
capacity: 128KiB
capabilities: synchronous internal write-back unified
configuration: level=1
*-cache:1
description: L2 cache
physical id: 43
slot: L2 Cache
size: 512KiB
capacity: 512KiB
capabilities: synchronous internal write-back unified
configuration: level=2
*-cache:2
description: L3 cache
physical id: 44
slot: L3 Cache
size: 4MiB
capacity: 4MiB
capabilities: synchronous internal write-back unified
configuration: level=3
*-memory UNCLAIMED
description: Memory controller
product: 200 Series PCH PMC
vendor: Intel Corporation
physical id: 1f.2
bus info: pci@0000:00:1f.2
version: 00
width: 32 bits
clock: 33MHz (30.3ns)
capabilities: bus_master
configuration: latency=0
resources: memory:dff44000-dff47fff

keep in mind I’m really new and I am learning console commands but I dont understand the structure or terminology yet so I need a really good explanation as to what output you need to help me, along with explanation of what the command is doing.

I have broken a few systems in the past because of broken packages, copying and pasting commands from forums like OMGUbuntu! I really like this setup. I dont want to reinstall again. .

Sorry this was so long and thank you for your time!

Hi, as a relatively new user as well (2 years) this is the first time I’m encountering that specific command, the point I would make is not helpful in answering your question, though.

I’m sure someone with the technical knowledge will be able to answer, but for what it’s worth I’ve noticed on multiple distros and desktop environments that after closing a bunch of applications (after a few hours of uptime) that memory readings won’t go back to how it was on a fresh startup and after a quick search online it seems that it doesn’t harm performance.

Sorry if I misunderstood and your RAM increases until it’s full but 30% seems about normal.

Can someone confirm if it’s like “cached” RAM?

As far as I know after you start a program it can (doesn’t necessarily) leave processes running even after you close it depending on the program which can account for a higher memory consumption than startup

A couple of possibilities for you to explore: if your panel is indicator-multiload applet, it seems to show memory in GB. Mate System Monitor displays in GiB–so it should be a lower number.

I don’t use htop, but “free -h” on my system shows an even lower number in GB–though if you read the manual “man free” the number is specified as being GiB. The distinction didn’t make much difference when the prefixes were K and M, but really shows with G and T and up.

Linux also uses kernel buffers, page cache, slabs, and shared memory to improve efficiency in memory and disk usage. Nearly all of that will be automatically recovered by the kernel if needed for use by an application.

Unless you consistently start one particular application, and then slowly see memory use rise until you start swapping, I wouldn’t spend effort second guessing how the kernel allocates memory. Almost always, it just works.

You read it right. I’m not a very good writer so I end up writing pages and pages. It never fills up and has to swap, I just didn’t expect my Ubuntu system to hog RAM like Windows does. 30% seemed like a lot while idling. Thanks to some additional reading and these awesome replies, I learned Im using less than I thought, and Linux is great to control the memory usage through terminal.

Thank you so much for this information. I never used free -h. Here is my output while replying to this post, a few Caja directories open, running Steam client, and PlayOnLinux:

               total        used        free      shared  buff/cache   available
Mem:           7.7G        1.4G        170M        237M        6.1G        5.8G
Swap:          2.0G          0B        2.0G

I didnt get it that low until I uninstalled dropbox and removed some applets from the panel.
I have also learned how to clear cache if I need with this command:

$ sync; echo 3 | sudo tee /proc/sys/vm/drop_caches

This is one thing I was trying to say but couldn’t quite put into words right, or didn’t think of it while I was posting. I have been troubleshooting getting old windows games working in Wine with winetricks and sometimes they would crash or I would have to pkill <game.exe> to end the processes. Even after I would double check that those processes weren’t running (using htop) I noticed the RAM allocated to those processes never let up and as soon as I started using more than 30% I would get a bit upset and reboot.

Thanks again everyone for clearing this up for me. I’m learning how to maintain my machine more each day and that is awesome. I couldn’t do this without you awesome Ubuntu people!

There are plenty of resources on understanding the output of “free” but the basic idea is that the kernel will use every bit of memory it can in application buffers and disk cache to speed up operations. But any and all of that will be released immediately when needed for application or kernel use. The number most important for you is “available” not the “free” column.

Memory sitting totally unused is a wasted resource, so the kernel leaves anything it “thinks” it might ever have any reason to use again sitting in RAM. Under normal circumstances, you should never need to manually clear the caches. The kernel will do that on the fly when any of that memory is needed for any reason. You may not ever hit data already sitting in a cache again–but what you do hit is lightning fast compared with re-reading from the disk, even if you have SSDs. By clearing caches, you are most likely slowing your system down.

I like to check for processes with "ps -eF | grep " where name is some part of the process name. Scanning top or htop for names is tiresome with a few hundred processes.

I am curious, though: How you were finding out that ram was still allocated to a process if they are no longer in the htop list? If it is still in the list, it may be stopped, but not removed.

I was confused initially about what kill (and pkill) actually does (it is not necessarily kill): they send signals to processes–one of a choice of many signals. The default is SIGTERM (-15), which requests a process to end itself and its children gracefully. If the process is hung, it will not respond to the signal, in which case you will have to manually SIGKILL (-9) each process and each child. But be aware that SIGKILL cannot be ignored and gives no time for graceful exit, so it is a last resort.

2 Likes

Thanks for taking the time to educate me. I had just assumed the RAM allocated to those processes never letup because the percentage of memory used in the GUI system resource app didn’t change after I would “kill” those applications either with htop or through pkill <.exe> command.

Thank you for clarifying the non-importance of manually clearing cashed memory. I would rather have recent data stored in RAM than reading off the disc all the time. I have a Seagate 7200 RPM HDD and I wouldn’t call it super quiet, it is nothing like a WD Blue I have in another machine, that one is really silent. Silence is golden to me.

Regarding pkill, I have only used that command to end some games such as Skyrim, running in Wine through PlayOnLinux. Reason being is sometimes they crash upon exit and when it does I cant go back to my desktop environment. I can bring up a terminal though and hit xkill and click the Skyrim window. After doing xkill though the system resources app displays the same amount of RAM percentage and even CPU usage display as when they were running. Also I can still here the CPU fan running like it is processing the game untill I do something like pkill <.exe >

I have seen the SIGKILL command in htop and used it to remove process like firefox as a test, but I’ve never used it in the terminal by myself and I don’t know how that would be typed to do it right.

I’m really new to this and I know more commands than are good for me I guess. I remember too much stuff and don’t learn enough about it before I hack away. I swear I’m like a thousand apes on typewriters.