squeeze - squeeze memory from the system
squeeze [flag] amount
squeeze will allocate a region of its virtual memory of a size given by
its arguments, and lock that virtual memory down into real memory, thus
making it unavailable to other processes. It can only be used by the
The amount of memory locked is specified as an integer argument, in units
given by the flag argument. By default it is in megabytes (-m flag). A
flag of -p, implies that the amount is in pages; a flag of -k implies
that the amount in kilobytes; and a flag of -% implies a percentage of
the installed memory.
Once the memory is locked down, squeeze prints a message on stdout saying
how much is locked, and sleeps indefinitely. It can be interrupted by
SIGINT or SIGTERM, at which time it frees up the memory and exits. The
user should wait until after this message is printed before doing any
squeeze can be used to determine the approximate working set of a
program. To do so, use a machine which has enough physical memory to
allow your target application to run without any paging (other than
startup). This can be determined by using the command ssusage to spawn
your application. When the application exits, its resource usage is
printed; the value labeled majf gives the number of major page faults,
that is the number of faults that required a physical read to satisfy.
When run on a machine with a large amount of physical memory, this value
is the number of faults needed to start the program, which is the minimum
number for any run.
Then run squeeze to lock down varying amounts of memory, and rerun the
program. The major-fault number will remain low at first, but as you
squeeze out more and more memory, it will rise. The amount of physical
memory in the system minus the amount of memory squeezed at point at
which your application begins to page-fault tells you the combined
working set of your program, the kernel, and all other applications you
normally have running. If you have previously done this on a program
whose paging behavior is well understood, you can determine the working
set of the kernel and your normal environment, and by subtraction, the
working set of the application you are studying.
One program that can be used for this purpose is thrash(1). It allocates
a large block of memory, and then sequentially accesses each page in the
block. For all practical purposes, the working set of this program is
the size of the memory allocated.
PPPPaaaaggggeeee 2222 [ Back ]