Академический Документы
Профессиональный Документы
Культура Документы
May the source be with you, but remember the KISS principle ;-)
Softpanorama Search
Summary
A system’s virtual memory is a combination of the available random access memory
(RAM) and disk space. Portions of the virtual memory are reserved as swap space.
Swap space can be defined as a temporary storage location that is used when system’s
memory requirements exceed the size of available RAM. The default page size for
Solaris is 8K. Usual size of Solaris swap partition is the size of RAM.
1 of 10 10/1/2010 8:06 AM
Swap Space and Virtual Memory http://www.softpanorama.org/Solaris/Processes_and_memory/swap_spa...
To add a swap slice Edit the /etc/vfstab file to add information describing the swap slice.
Note – When the system is subsequently rebooted, the new swap slice /dev /dsk/c1t0d0s3
will be automatically included as part of the swap space as a result of adding the entry to the
/etc/v fstab file.
Adding Swap Files. Swap files can be used when you need to add swap space and do not have a
free partition to use.
To add a swap file, complete the following steps:
1. Create a 1G swap file named swapfile in the partition that have enough free space, for
example directory.
5. To use a swap file when the system is subsequently rebooted, add an entry for the swap file
in the file.
# vi /etc/vfstab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot opt
/export/data/swapfile --swap -no -
2. To prevent the swap slice from being configured as part of the swap configuration during a reboot or
change of run level, edit the /etc/vfstab file, and remove the swap slice entry from the file.
2 of 10 10/1/2010 8:06 AM
Swap Space and Virtual Memory http://www.softpanorama.org/Solaris/Processes_and_memory/swap_spa...
To prevent the swap file from being configured as part of the swap configuration during a reboot or
change of run level, edit the /etc/vfstab file, and remove the swap file entry.
Note – The output of the df -h /export/data/swapfile command shows the space in use until you
remove the swap file.
Swap slices are used as virtual memory storage areas when the system does not have enough physical memory to
handle current processes.
The virtual memory system maps physical copies of files on disk to virtual addresses in memory. Physical
memory pages which contain the data for these mappings can be backed by regular files in the file system, or by
swap space. If the memory is backed by swap space it is referred to as anonymous memory because there is no
identity assigned to the disk space backing the memory.
Solaris uses the concept of virtual swap space, a layer between anonymous memory pages and the physical
storage (or disk-backed swap space) that actually back these pages. A system's virtual swap space is equal to the
sum of all its physical (disk-backed) swap space plus a portion of the currently available physical memory.
The need for large amounts of physical swap space is reduced because virtual swap space does not
necessarily correspond to physical (disk) storage.
A pseudo file system called SWAPFS provides addresses for anonymous memory pages. Because
SWAPFS controls the allocation of memory pages, it has greater flexibility in deciding what happens to a
page. For example, it might change the page's requirements for disk-backed swap storage.
3 of 10 10/1/2010 8:06 AM
Swap Space and Virtual Memory http://www.softpanorama.org/Solaris/Processes_and_memory/swap_spa...
The TMPFS file system is activated automatically in the Solaris environment by an entry in the /etc/vfstab
file. The TMPFS file system stores files and their associated information in memory (in the /tmp directory)
rather than on disk, which speeds access to those files. This results in a major performance enhancement for
applications such as compilers and DBMS products that use /tmp heavily.
The TMPFS file system allocates space in the /tmp directory from the system's swap resources. This means that
as you use up space in /tmp, you are also using up swap space. So if your applications use /tmp heavily and you
do not monitor swap space usage, your system could run out of swap space.
Use the following if you want to use TMPFS but your swap resources are limited:
Mount the TMPFS file system with the size option (-o size) to control how much of the swap resources
TMPFS can use.
If you are close to running out of swap space, you can use your compiler's environment variable
to point to a larger, real directory.
Using your compiler's variable only controls whether the compiler is using /tmp or not. It has no
effect on other programs' use of /tmp.
These messages indicate that an application was trying to get more anonymous memory and there was no swap
space left to back it.
malloc error O
This message is displayed if a page could not be allocated when writing a file. This can occur when TMPFS tries
to write more than it is allowed or if currently executed programs are using a lot of memory.
This message means TMPFS ran out of physical memory while attempting to create a new file or directory.
See TMPFS(7FS) for information on recovering from the TMPFS-related error messages.
4 of 10 10/1/2010 8:06 AM
Swap Space and Virtual Memory http://www.softpanorama.org/Solaris/Processes_and_memory/swap_spa...
Initially, swap space is allocated as part of the Solaris installation process. If you use the installation program's
automatic layout of disk slices and do not manually change the size of the swap slice, the Solaris installation
program allocates default swap slices as shown in the table below.
If Your System Has n Mbytes of Physical Memory ... Then the Default Swap Space Allocated Is ...
16-63 32 Mbytes
64-127 64 Mbytes
Additional swap space can also be added to the system by creating a swap file. See "Adding More Swap Space"
for information about creating a swap file.
Because the file system containing a swap file must be mounted before the swap file is activated, make sure that
the entry that mounts the file system comes before the entry that activates the swap file in the /etc/vfstab file.
Consult your application vendor for swap space requirements for any application whose data files typically
exceed 10-20 Mbytes in size.
If you are unable to determine swap space requirements from the application vendor, use the following
guidelines to allocate swap space:
If you are unsure of system or application requirements 100% of the system's physical memory. You need
more that that if you plan to run a lot of application. To support all your applications, you need to allocate
allocate:
1 Mbyte per trivial application such as xterm.
2-3 Mbytes per lightweight application such as a calendar or mail application.
20-50 Mbytes for large applications such as desktop publishing software.
To save crash dumps, allocate 100% of physical memory to save a worst-case crash dump.
5 of 10 10/1/2010 8:06 AM
Swap Space and Virtual Memory http://www.softpanorama.org/Solaris/Processes_and_memory/swap_spa...
Determine whether large applications (like compilers) will be using the /tmp directory.
Use the swap -l command to identify a system's swap areas. Activated swap devices or files are listed under the
column.
swap -l
swap -s
The plus figures equals total swap space on the system, which includes a portion of physical
memory and swap devices (or files).
You can use the amount of swap space available and used (in the swap -s output) as a way to monitor swap
space usage over time. If a system's performance is good, use swap -s to see how much swap space is available.
When the performance of a system slows down, check the amount of swap space available to see if it has
decreased. Then you can identify what changes to the system might have caused swap space usage to increase.
Keep in mind when using this command that the amount of physical memory available for swap usage changes
dynamically as the kernel and user processes lock down and release physical memory.
Note - The swap -l command displays swap space in 512-byte blocks and the swap -s command displays swap
space in 1024-byte blocks. If you add up the blocks from swap -l and convert them to Kbytes, it will be less
than + (in the swap -s output) because swap -l does not include physical memory in its
calculation of swap space.
The output from the swap -s command is summarized in the table below.
Keyword Description
The total amount of swap space in 1024-byte blocks that is currently allocated as backing
store (disk-backed swap space).
The total amount of swap space in 1024-byte blocks not currently allocated, but claimed
by memory for possible future use.
The total amount of swap space in 1024-byte blocks that is either allocated or reserved.
6 of 10 10/1/2010 8:06 AM
Swap Space and Virtual Memory http://www.softpanorama.org/Solaris/Processes_and_memory/swap_spa...
Keyword Description
The total amount of swap space in 1024-byte blocks that is currently available for future
reservation and allocation.
Alternative ways to add more swap space are to repartition an existing disk or add another disk. See Chapter 28,
Disk Management (Overview) for information on how to repartition a disk.
The mkfile command creates a file that is suitable for use either as an NFS-mounted or local swap area. The
sticky bit is set, and the file is filled with zeros. You can specify the size of the swap file in bytes (the default) or
in kilobytes, blocks, or megabytes using the k, b, or m suffixes, respectively.
Option Description
-n Creates an empty file. The size is noted, but the disk blocks are not allocated until data is written
to them.
1. Become superuser.
You can create a swap file without root permissions, but it is a good idea for root to be the owner of the
swap file to avoid accidental overwriting.
7 of 10 10/1/2010 8:06 AM
Swap Space and Virtual Memory http://www.softpanorama.org/Solaris/Processes_and_memory/swap_spa...
The swap file of the size nnn (in Kbytes, bytes, or Mbytes) and name you specify is created.
# /usr/sbin/swap -a /path/filename
You must use the absolute path name to specify the swap file. The swap file is added and available until
the file system is unmounted, the system is rebooted, or the swap file is removed. Keep in mind that you
can't unmount a file system while some process or program is swapping to the swap file.
4. Add an entry for the swap file to the /etc/vfstab file that specifies the full path name of the file, and
designates swap as the file system type, like this:
/path/filename - - swap - no -
5. Verify that the swap file is added.
$ /usr/sbin/swap -l
The following examples shows how to create a 24 Mbyte swap file called /files/swapfiles.
# mkdir /files
# mkfile 24m /files/swapfile
# swap -a /files/swapfile
# vi /etc/vfstab
(An entry is added for the swap file):
/files/swapfile - - swap - no -
# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c0t2d0s1 32,17 8 205624 192704
/files/swapfile - 8 40952 40952
1. Become superuser.
2. Use the swap -d command to remove swap space.
# /usr/sbin/swap -d /path/filename
The swap file name is removed from the list so that it is no longer available for swapping. The file itself is
not deleted.
3. Edit the /etc/vfstab file and delete the entry for the swap file.
4. Recover the disk space so that you can use it for something else.
8 of 10 10/1/2010 8:06 AM
Swap Space and Virtual Memory http://www.softpanorama.org/Solaris/Processes_and_memory/swap_spa...
# rm swap-filename
If the swap space is a file, remove it. Or, if the swap space is on a separate slice and you are sure you will
not need it again, make a new file system and mount the file system.
See Chapter 36, Mounting and Unmounting File Systems (Tasks) for information on mounting a file
system.
The following examples shows how to delete the /files/swapfile swap file.
swap -d /files/swapfile
rm /files/swapfile
swap -l
Recommended Links
In case of broken links please try to use Google search. If you find the page please notify us about new location
Solaris Internals
Solaris processes
Beginning with the Solaris 9 OS, multiple page sizes can be supported on UltraSPARC processors so
administrators can optimize performance by changing the page size on behalf of an application. Typical
performance measurement tools do not provide sufficient detail for evaluating the impact of page size and do
not provide the needed support to make optimal page size choices.
This article explains how to use new tools to determine the potential performance gain. In addition, it explains
how to configure larger page sizes using the multiple page size support (MPSS) feature of the Solaris 9 OS.
The article addresses the following topics:
9 of 10 10/1/2010 8:06 AM
Swap Space and Virtual Memory http://www.softpanorama.org/Solaris/Processes_and_memory/swap_spa...
Copyright © 1996-2009 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development
Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created
exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Site uses AdSense so you need to be
aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in
compliance with the fair use doctrine.
Disclaimer:
The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily
reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with.
We do not warrant the correctness of the information provided or its fitness for any purpose
In no way this site is associated with or endorse cybersquatters using the term "softpanorama" with other main or country domains with
bad faith intent to profit from the goodwill belonging to someone else.
10 of 10 10/1/2010 8:06 AM