A recent Sun article advises readers on how to determine how much free
physical RAM they have available and how to effectively use this
information. Users of the SolarisTM Operating System (Solaris OS)
will find the document provides a routine to determine available
physical memory, as well as a sample program that demonstrates how the
interface can be used.
The article explains how an evaluation from within the program of how
much free physical memory can be used without causing paging to disk is
required before achieving any kind of space/time tradeoff. There are a
variety of reasons why such an evaluation and later usage of the
information can be difficult, including:
- Different systems provide different ways (if any) to determine
the amount of free physical memory available at the moment. The
method to obtain this information is highly platform-dependent.
- The amount of free memory you get is subject to various race
conditions, particularly under multi-user and multi-processing
operating systems (which almost all of them are nowadays).
- An application may or may not have knowledge of its own memory
requirements in the future. For example, interactive applications'
future memory requirements may depend on the actions of the user
(which are unknown so far).
The article also looks at some of the ways application programs can
trade available physical memory for speed:
- Table lookup: In many cases, a user can precompute a number of
values, save them in memory, and then look up the result instead of
- Caching: Instead of computing the result or
transferring it from a remote location each time, a user can store
the result in memory and reuse it when it is needed again later.
- Hashing: Provides a fast way to search a large, unsorted
data set at the cost of extra memory.
- Using display lists for OpenGLR graphics: An OpenGL display list
is a specially optimized cache of OpenGL commands stored locally.
Other sections in the article include:
- How to Determine Available Physical Memory Under the Solaris OS
- Detecting Paging to Disk from Your Program
- Improving Application Performance by Using Available Memory
- Example: Compute Population Counts
The article recommends avoiding paging to disk as much as possible, no
matter the amount of theoretical performance improvements. The article
primarily focuses on the tricky business of finding free physical
memory and using it productively without causing any paging to disk.
For the complete article, see:
Read More ...