Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

memstat(1) [debian man page]

MEMSTAT(1)						     Linux Programmer's Manual							MEMSTAT(1)

memstat - Identify what's using up virtual memory. SYNOPSIS
memstat [-w][-p PID] DESCRIPTION
memstat lists all accessible processes, executables, and shared libraries that are using up virtual memory. To get a complete list memstat has to be run as root to be able to access the data of all running processes. First, the processes are listed. An amount of memory is shown along with a process ID and the name of the executable which the process is running. The amount of memory shown does not include shared memory: it only includes memory which is private to that process. So, if a process is using a shared library like libc, the memory used to hold that library is not included. The memory used to hold the exe- cutable's text-segment is also not included, since that too is shareable. After the processes, the shared objects are listed. The amount of memory is shown along with the filename of the shared object, followed by a list of the processes using the shared object. The memory is listed as the total amount of memory allocated to this object throughout the whole namespace. In brackets also the amount that is really shared is listed. Finally, a grand total is shown. Note that this program shows the amount of virtual (not real) memory used by the various items. memstat gets its input from the /proc filesystem. This must be compiled into your kernel and mounted for memstat to work. The pathnames shown next to the shared objects are determined by scanning the disk. memstat uses a configuration file, /etc/memstat.conf, to determine which directories to scan. This file should include all the major bin and lib directories in your system, as well as the /dev directory. If you run an executable which is not in one of these directories, it will be listed by memstat as ``[0dev]:<inode>''. Options The -w switch causes a wide printout: lines are not truncated at 80 columns. The -p switch causes memstat to only print data gathered from looking at the process with the gicen PID. NOTES
These reports are intended to help identify programs that are using an excessive amount of memory, and to reduce overall memory waste. FILES
/etc/memstat.conf /proc/*/maps SEE ALSO
ps(1), top(1), free(1), vmstat(8), lsof(8), /usr/share/doc/memstat/memstat-tutorial.txt.gz BUGS
memstat ignores all devices that just map main memory, though this may cause memstat to ignore some memory usage. Memory used by the kernel itself is not listed. AUTHOR
Originally written by Joshua Yelon <> and patched by Bernd Eckenfels <>. Taken over and rewritten by Michael Meskes <>. Debian 01 November 1998 MEMSTAT(1)

Check Out this Related Man Page

SHM_OVERVIEW(7) 					     Linux Programmer's Manual						   SHM_OVERVIEW(7)

shm_overview - overview of POSIX shared memory DESCRIPTION
The POSIX shared memory API allows processes to communicate information by sharing a region of memory. The interfaces employed in the API are: shm_open(3) Create and open a new object, or open an existing object. This is analogous to open(2). The call returns a file descriptor for use by the other interfaces listed below. ftruncate(2) Set the size of the shared memory object. (A newly created shared memory object has a length of zero.) mmap(2) Map the shared memory object into the virtual address space of the calling process. munmap(2) Unmap the shared memory object from the virtual address space of the calling process. shm_unlink(3) Remove a shared memory object name. close(2) Close the file descriptor allocated by shm_open(3) when it is no longer needed. fstat(2) Obtain a stat structure that describes the shared memory object. Among the information returned by this call are the object's size (st_size), permissions (st_mode), owner (st_uid), and group (st_gid). fchown(2) To change the ownership of a shared memory object. fchmod(2) To change the permissions of a shared memory object. Versions POSIX shared memory is supported since Linux 2.4 and glibc 2.2. Persistence POSIX shared memory objects have kernel persistence: a shared memory object will exist until the system is shut down, or until all pro- cesses have unmapped the object and it has been deleted with shm_unlink(3) Linking Programs using the POSIX shared memory API must be compiled with cc -lrt to link against the real-time library, librt. Accessing shared memory objects via the filesystem On Linux, shared memory objects are created in a (tmpfs(5)) virtual filesystem, normally mounted under /dev/shm. Since kernel 2.6.19, Linux supports the use of access control lists (ACLs) to control the permissions of objects in the virtual filesystem. NOTES
Typically, processes must synchronize their access to a shared memory object, using, for example, POSIX semaphores. System V shared memory (shmget(2), shmop(2), etc.) is an older shared memory API. POSIX shared memory provides a simpler, and better designed interface; on the other hand POSIX shared memory is somewhat less widely available (especially on older systems) than System V shared memory. SEE ALSO
fchmod(2), fchown(2), fstat(2), ftruncate(2), mmap(2), mprotect(2), munmap(2), shmget(2), shmop(2), shm_open(3), shm_unlink(3), sem_over- view(7) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at Linux 2016-12-12 SHM_OVERVIEW(7)
Man Page

Featured Tech Videos