What is the command to find the RAM size in computer? I want to see result in MB.
Ubuntu – How to check RAM size
ram
Related Solutions
The swap partition is used to
- move temporarily running programs that are not active,so that to make space for the programs being used.
- for hibernation, where your entire RAM is copied to the swap partition.
Therefore, if you will be using hibernation, you should have a swap at least as big as your RAM, and a bit more just in case.
A rule of thumb is to make a swap partition as big as twice your RAM but not go over 3GB (because you will be wasting space).
It is OK to create a second swap partition and have them both active. Linux uses them as if they were a continuous swap partition, so it is fine.
Typically, if you have over 3GB of RAM, then you will notice that Ubuntu will not have a use of your swap. Run the free
command and notice the value for Swap:
+ used
. In most cases it just stays to 0.
There's a very good detailed explanation here: https://blogs.kde.org/2005/09/15/measuring-memory-usage
But essentially: You have to really dig in and understand how the application is set up.
So for example, looking at mysql:
PID PPID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6004 16116 composit 20 0 37900 27m 2908 S 0 0.2 0:40.33 mysqld
16115 16085 composit 20 0 37900 27m 2908 S 0 0.2 0:00.37 mysqld
16116 16115 composit 20 0 37900 27m 2908 S 0 0.2 2:07.34 mysqld
16117 16116 composit 20 0 37900 27m 2908 S 0 0.2 0:00.00 mysqld
16118 16116 composit 20 0 37900 27m 2908 S 0 0.2 3:19.79 mysqld
16119 16116 composit 20 0 37900 27m 2908 S 0 0.2 0:00.01 mysqld
16120 16116 composit 20 0 37900 27m 2908 S 0 0.2 5:31.09 mysqld
16121 16116 composit 20 0 37900 27m 2908 S 0 0.2 14:19.53 mysqld
16122 16116 composit 20 0 37900 27m 2908 S 0 0.2 36:13.67 mysqld
16123 16116 composit 20 0 37900 27m 2908 S 0 0.2 30:30.64 mysqld
16124 16116 composit 20 0 37900 27m 2908 S 0 0.2 0:00.15 mysqld
16493 16116 composit 20 0 37900 27m 2908 S 0 0.2 0:00.00 mysqld
The total memory used is about 25 MB (Take the 27 MB RES and subtract the shared (SHR))
I validated this by checking the total memory usage (free -m, +/ buffers/cache) before and after issuing a "killall mysqld". After killing all mysqld processes, the memory usage dropped by 25 MB according to "free -m".
If you see that each process has identical VIRT, RES, and SHR columns, they are likely just threads of the same process. (Older Linux libraries handled threading by spawning multiple real processes that essentially occupied the same memory)
If they are different, you might be able to estimate it by doing a SUM of (RES - SHR). But that only works if the processes are in fact separate processes and not just threads of the same process. Looking at the PPID (Parent Process ID) also helps. If they all have the same parent, they are probably just threads (Though not necessarily).
Unfortunately there's no real good easy way to answer this in Linux. The only easy way is to check "free" immediately before terminating the process and check it again immediately after. look at the "-/+ buffers/cache:" line and see how much memory usage decreased and that will tell you how much it was using.
Best Answer
From a terminal you should be able to use:
From
man
page:Note: A kilobyte (kB) is 1000 Bytes.