Ubuntu has been crashing on me recently. I think its because it runs out of memory so I ran the free -m
command and found that my memory usage was really high. So then, i ran top
to find the culprit, but the displayed processes were using less than 1.5% of memory. How do I know which program is making ubuntu crash/run out of memory? Below is the output:
shafee@shafee-pc:~$ free -m
total used free shared buffers cached
Mem: 3824 3714 110 0 978 1954
-/+ buffers/cache: 780 3044
Swap: 99 0 99
shafee@shafee-pc:~$ top
top - 02:12:14 up 1:24, 2 users, load average: 0.16, 0.42, 1.49
Tasks: 182 total, 1 running, 181 sleeping, 0 stopped, 0 zombie
Cpu(s): 2.9%us, 1.9%sy, 0.3%ni, 79.3%id, 15.5%wa, 0.0%hi, 0.2%si, 0.0%st
Mem: 3916708k total, 3803848k used, 112860k free, 1002308k buffers
Swap: 102396k total, 0k used, 102396k free, 2001852k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4200 root 20 0 289m 53m 38m S 2 1.4 1:06.45 Xorg
5590 shafee 20 0 19348 1368 956 R 2 0.0 0:00.01 top
1 root 20 0 24124 2136 1264 S 0 0.1 0:02.05 init
2 root 20 0 0 0 0 S 0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0 0.0 0:24.23 ksoftirqd/0
6 root RT 0 0 0 0 S 0 0.0 0:00.00 migration/0
7 root RT 0 0 0 0 S 0 0.0 0:00.00 migration/1
9 root 20 0 0 0 0 S 0 0.0 0:00.11 ksoftirqd/1
11 root RT 0 0 0 0 S 0 0.0 0:00.00 migration/2
13 root 20 0 0 0 0 S 0 0.0 0:03.89 ksoftirqd/2
14 root RT 0 0 0 0 S 0 0.0 0:00.00 migration/3
16 root 20 0 0 0 0 S 0 0.0 0:00.16 ksoftirqd/3
17 root 0 -20 0 0 0 S 0 0.0 0:00.00 cpuset
18 root 0 -20 0 0 0 S 0 0.0 0:00.00 khelper
19 root 0 -20 0 0 0 S 0 0.0 0:00.00 netns
21 root 20 0 0 0 0 S 0 0.0 0:00.01 sync_supers
shafee@shafee-pc:~$
Or is it normal to have 110mb of free memory and is my issue related to something else?
You are reading the output of
free
incorrectly. The Linux Kernel does a lot of its own memory management, in turn allocating more than it actually needs - so your true amount of "Free Memory" is3044
located in the "Free" column of the+/- Buffers/cache
line, making only 780 MB actually being consumed.By default
top
will sort based on CPU consumption. You can press Shift+M to sort by percentage of memory consumed - giving you a better grasp of what software is using the memory allotted to the kernel.And in top with memory sorted:
Finally to help you diagnose what the actual software is, try passing the
-c
flag to top:top -c
as that will give you the full path, name, and parameters of the command running.You can use the following script to see total memory usage by individual applications in your GNU Linux system
http://www.zyxware.com/articles/4446/show-total-memory-usage-by-each-application-in-your-ubuntu-or-any-gnu-linux-system
You can start the application gnome-system-monitor It's the best to find out how much ram is used by what apps, also how much cpu is used also. You can change the priority of a process to run even faster , for example if you want to convert video etc etc.
This is a good question but the information shows there is lots of memory available. You should be monitoring your memory usage though.
My favorite system monitor is
conky
and memory display is part of it:Total memory line shows 2.5 GiB out of 7.4 GiB is being used.
Detailed memory line shows:
Web Content
is using 7% of memory. This is a Firefox subprogram.Firefox
itself is using 7% of memoryffmpeg
is using 3% of memory. This is the.gif
recorderpeek
making the video we are watching.Conky is highly configurable and everyone's desktop looks different. You can google
conky
and get 787 thousand hits.In Kubuntu I just press Ctrl-Esc and then sort things using field of interest: Memory, CPU, ...
I had this challenge when working on an Ubuntu 20.04 machine.
Let me add my 2 cents to this question:
Your actual free/unallocated memory is 110MB
The buffer/cache/allocated memory which is 3044 is actually free memory but it's already allocated.
This is what happens. As you use more applications on your laptop, your buffer/cache/allocated memory increases, by allocating more memory specifically to those applications. This memory increases to allow you to easily access those applications in memory, which increases performance.
However, newer applications may now have to struggle with the free/unallocated memory left, because the buffer/cache/allocated memory even though they are free, they have already been allocated to some set of applications that you are currently using.
I found some script online that helps you free up some buffer/cache/allocated memory for other applications to use without restarting your machine. You may have to run the script once a day/week.
Resources: How do you find out which program is using too much memory?
That's all.
I hope this helps