Wednesday, November 12, 2008

Troubleshooting virtual memory

Process Virtual Memory

Source:

http://www.princeton.edu/~unix/Solaris/troubleshoot/vm.html

Each process maps either 2^32 or 2^44 bytes of memory (depending on whether the OS is running in 32 or 64-bit mode). This works out to 4GB or 16TB. Not all of this memory is allocated (used); the virtual memory is used as address space that can be mapped to actual memory resources.

Virtual memory structure for a process can be described as in this diagram:

Kernel

While this is part of the address space, it cannot be addressed directly by the process. It must be addressed via system calls.
Stack

Used by the program for variables and storage. It grows and shrinks in size depending on what routines are called and what their stack space requirements are. It is normally about 8MB in size.
Shared Libraries
Shared libraries are position independent so that they can be shared by all programs that want to use them. One common example is libc.so.
hole

This is the address space that is unallocated and unused. It does not tie up physical memory. For most processes, this is the largest portion of the virtual memory for the process.
heap

Used for some types of working storage. It is allocated by the malloc function.
BSS

Uninitialized variables. These are not part of the executable file and their initial value is set to zeros.
Data

Global variables, constants, static variables from the program.
Text

Set of instructions from the compiler-generated executable file.

The virtual memory map for a process can be displayed using the pmap command.

Additional information is available on the Processes page.

No comments: