How do I check used and free RAM memory usage under Linux operating systems using command line and GUI tools?
Linux comes with different set of commands to check memory usage. The free command displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. The vmstat command reports information about processes, memory, paging, block IO, traps, and cpu activity. Finally, you can use the top command which provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.
free command
Display free memory size in MB:
$ free -m
Output:
total used free shared buffers cached Mem: 750 625 125 0 35 335 -/+ buffers/cache: 254 496 Swap: 956 0 956
Displays a line containing the totals memory in MB:$ free -t -m
Output:
total used free shared buffers cached Mem: 750 625 125 0 35 335 -/+ buffers/cache: 253 496 Swap: 956 0 956 Total: 1707 625 1082
vmstat command
Type vmstat command at shell prompt:
$ vmstat
Output:
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 1 0 0 131620 35432 341496 0 0 42 82 737 1364 15 3 81 1
top command
Type top command at the shell prompt:$ top
Sample outputs:
To exit from top command type q key. Read man page of free, vmstat, top command for more information.
GNOME Desktop: GUI Tool
The Gnome System Monitor application enables you to display basic system information and monitor system processes, usage of system resources, and file systems. You can also use System Monitor to modify the behavior of your system. You can start System Monitor by visiting System menu > Choose Administration > System Monitor option. Or type the following command at the shell prompt:
gnome-system-monitor
Sample outputs:
----------------------------------------------------------------------------------------
2. How to Check Shared Memory on Linux
Shared memory is responsible for the smooth operation of your system; it acts as a space that multiple programs can access at once. This enables those programs to communicate in sync, while avoiding file redundancy. Shared memory can exist in the system's physical RAM or the swap file (which is virtual memory). InLinuxoperating systems, check the details of shared memory by typing in a few simple commands.
Instructions
-
1
Power on yoursystemand log in.
-
2
Open a "Terminal" window.
-
3
Type in "cat /proc/sys/kernel/shmall" and press "Enter." You'll see the total amount of shared memory available displayed in bytes.The max size of a shared memory segment is displayed with "cat/proc/sys/kernel/shmmax", and the total number of segments in the system is displayed with "cat /proc/sys/kernel/shmmni".
Read more:How to Check Shared Memory on Linux | eHow.comhttp://www.ehow.com/how_6849046_check-shared-memory-linux.html#ixzz19eUg5rtL
-------------------------------------------------------------------------------------------
3. Shared Memory Configuration
McIDAS-X 200xuses shared memory for a variety of tasks including frame allocation. By default, the shared memory facility is activated and should have sufficient maximum segment size on HP, IBM and SGI systems. However, this is not true for Sun systems running Solaris 2.xor Digital systems running True64.On Linux systems, the amount of available shared memory appears is equivalent tothe combination of physical RAM and swap.
The system administrator should complete the steps below the first time McIDAS-X 200xis installed on Sun Solaris or Digital True64 workstations or if they desire to increase shared memory defaults on HP, IBM, or SGI systems.
Sun Solaris 2.X
SGI IRIX 6.x
HP HP-UX 10, 11
IBM AIX
Compaq Tru64 UNIX
RedHat Linux
FreeBSD 4.[789]
MacOS-X 7.4.0
Sun Solaris 2.x
The system administrator must complete the steps below the first time McIDAS-X is installed on a Sun workstation running Solaris 2.x.
1. Force the kernel to activate the shared memory system at boot time by adding the line below to the appropriate location in the file
/etc/system.
forceload: sys/shmsys |
2. Check the maximum size of a shared memory segment using the command below. The value is indicated in bytes; the example lists a 512 MB maximum shared memory segment.
If your value is less than 512 MB, go to step 3. If your value is 512 MB or greater, go to step 4.
3. Set the shared memory size to 512 MB by adding the line below to theappropriate location in the file/etc/system.
set shmsys:shminfo_shmmax = 536870912 |
4. Reboot the system so the forceload entry and 512 MB maximum shared memory size take effect.
SGI IRIX 6.x
On Irix, SHMMAX defaults to 512 MB (0x20000000 bytes), so tuning this parameter is unlikely to be needed. SHMMAX is found in/var/sysgen/mtune/shm.
HP HP-UX 10, 11
On HP-UX 10 and 11, the maximum value for SHMMAX is 1024 MB (0x40000000; the default value for 64 MB (0x04000000). SHMMAX is found in/etc/conf/master.d/core-hpux.
The procedure for changing the parameter is similar, if not identical, to the one described for HP-UX 9.
One way to check the current value of SHMMAX is to enter the following command:
Type:grep SHMMAX /etc/master
If the grep does not print anything, you are using the default value of 64 MB. If the grep prints something, the output might look like this:
shmmax SHMMAX 0X20000000 |
The value isbytes, so here the maximum segment size has been set to 512 MB.
IBM AIX 4.x
The shmget(2) man page says that the maximum shared-memory segment size is 256 MB (0x10000000); this limit does not appear to be tunable.
Compaq Tru64 UNIX
The easiest way to increase shared-memory allocation on True64 is to use the GUI calleddxkerneltuner, but one can also use thesysconfigdbcommand-line interface.
Runningdxkerneltunerand increasing the shared-memory size to 64 MB will result in the following entry in the file /etc/sysconfigtab:
ipc: shm-max=67108864
The following are the out-of-the-box defaults for the ipc subsystem for OSF/1 Version 4.0. They may be helpful for True64:
% sysconfig -q ipc ipc: msg-max = 8192 msg-mnb = 16384 msg-mni = 64 msg-tql = 40 shm-max = 4194304 shm-min = 1 shm-mni = 128 shm-seg = 32 sem-mni = 16 sem-msl = 25 sem-opm = 10 sem-ume = 10 sem-vmx = 32767 sem-aem = 16384 num-of-sems = 60 max-kernel-ports = 22487 port-hash-max-num = 1124350 port-reserved-max-num = 22487 set-max-num = 1029 ssm-threshold = 8388608 ssm-enable-core-dump = 1
RedHat Linux
There appears to be two ways of (re)defining the amount of shared memory in your system (tips thanks to Dave Glowacki of SSEC):
- add this line to your /etc/rc.d/rc.local file:
echoshared_memory_size> /proc/sys/kernel/shmmax
(whereshared_memory_sizeis the amount of shared memory you want to declare in bytes) and reboot.
Note:since this will be the last thing run before your system comes up, your McIDAS session won't get a larger shared memory segment if it's started during the boot process).
- a more permanent solution would be to change the value of SHMMAX in/usr/src/linux/include/asm/shmparam.hand rebuild your kernel
FreeBSD 4.[789]
Shared memory parameters are only read when the system goes from single user to multi user mode.
Add setting of shared memory max to/etc/sysctl.conf
# $FreeBSD: src/etc/sysctl.conf,v 1.1.2.3 2002/04/15 00:44:13 dougb Exp $ # # This file is read when going to multi-user and its contents piped thru # ``sysctl'' to adjust kernel values. ``man 5 sysctl.conf'' for details. # kern.ipc.shmmax=536870912
and then reboot.
MacOS-X 7.4.0 (Panther)
In the Panther release of MacOS-X, shared memory is set in the file/etc/rc. The default settings will look something like:
# System tuning sysctl -w kern.maxvnodes=$(echo $(sysctl -n hw.physmem) '33554432 / 512 * 1024 +p'|dc) sysctl -w kern.sysv.shmmax=4194304 sysctl -w kern.sysv.shmmin=1 sysctl -w kern.sysv.shmmni=32 sysctl -w kern.sysv.shmseg=8 sysctl -w kern.sysv.shmall=1024
We recommend changing this to:
# System tuning sysctl -w kern.maxvnodes=$(echo $(sysctl -n hw.physmem) '33554432 / 512 * 1024 +p'|dc) sysctl -w kern.sysv.shmmax=536870912 sysctl -w kern.sysv.shmmin=1 sysctl -w kern.sysv.shmmni=4096 sysctl -w kern.sysv.shmseg=4096 sysctl -w kern.sysv.shmall=131072
After making these changes, the system will need to be rebooted for the changes to take effect.
相关推荐
Shared Memory Communications for Linux on IBM Z — Jing Zhang KVM on IBM Z Development 2018内核开发者大会
Shared Memory Source Code for Linux.
Shared memory regions——Berkeley db共享内存区域介绍
介绍linux sharememory 相关的内容。
• Parallel Program and Shared Memory• Parallel Programming in Linux Kernel: Two
Linux系统原理性书籍,共享内存是进程间通讯(IPC)的一种机制。本书深入地剖析了这种机制的原理,举例说明了使用方法。
shared_memory 一个允许您在进程之间共享内存的板条箱。 此板条箱以与操作系统无关的方式为共享内存API提供轻量级包装。 它打算与它的姊妹板条箱一起使用,它提供简单的primitves来同步对共享内存(Mutex,RwLock,...
It has all the features you would expect in a modern fully-fledged Unix, including true multitasking, virtual memory, shared libraries, demand loading, shared copy-on-write executables, proper memory ...
mbuff.o模块和/ dev / mbuff旨在用作共享内存设备,从而可以使用vmalloc在内核中分配的内存映射到用户空间。 特别推荐用于RT-Linux任务/用户空间通信。
A Linux and UNIX® System Programming Handbook Chapter 1: History and Standards Chapter 2: Fundamental Concepts Chapter 3: System Programming Concepts Chapter 4: File I/O: The Universal I/O Model ...
Perform interprocess communication using pipes, message queues, shared memory, and semaphores Write network applications with the sockets API While The Linux Programming Interface covers a wealth of ...
shared memory, message queues, semaphores, POSIX, file handling, sockets, and more Provides detailed discussion of scripting and integration with the GNU/Linux environment with bash, including ...
Linux is a clone of the operating system Unix, written from scratch by Linus Torvalds with assistance from a loosely-knit team of hackers across the ...
基于Linux的一个记录客户写入情况的日志模块。 其中附有详细的ReadMe说明和代码注释。 关键字:Linux,日志模块,共享存储,多线程。... Keywords: Linux, the log module, shared memory, multi-threading.
這是一個shared memory的使用範例,使用到簡單的Linux API做共享記憶體的分配。
Not join protect to Shared Memory Segments,example Semaphore Arrays. Not check the parameters validity. When transmit may be error. If the client program no right exit,others cannot know,the service ...
1 INTRODUCTION 1 2 DESCRIBING PHYSICAL MEMORY 15 3 PAGETABLE MANAGEMENT 33 4 PROCESS ADDRESS SPACE 53 5 BOOT MEMORY ...12 SHARED MEMORY VIRTUAL FILESYSTEM 195 13 OUT OF MEMORY MANAGEMENT 209
一个利用信号量互斥访问shared memory的程序
Fast userlevel locking is an alternative locking mechanism to the typically heavy weight kernel approaches such as fcntl locking and System V semaphores....memory regions and atomic operations.
ISA shared memory and I O port support.