All Manuals > LispWorks® User Guide and Reference Manual > 47 The SYSTEM Package

set-memory-exhausted-callback Function


Sets a callback that is called when memory is exhausted in 64-bit LispWorks.




set-memory-exhausted-callback function &optional where => callbacks

A function designator, the keyword :reset, or nil.
:first, :last or nil.
A list of function designators.

The function set-memory-exhausted-callback adds a callback that is called when memory is exhausted. That is, when the system fails to map memory.

Note: set-memory-check is a more robust way to protect against memory exhaustion problems.

If function is a function designator then it should be a function with signature:

function gen-num size type-name static

function is expected to report what the system was trying to allocate when it failed to map memory. Its arguments are:

The number of the generation in which it was trying to allocate.
The size in bytes which it was trying to allocate.
A string naming the allocation type it was trying to allocate.
A boolean, true if it was trying to allocate a static object, and false otherwise.

function can also have the special value :reset, which resets the callback list to nil.

function can also be nil, which means do nothing but simply return the current list of callbacks.

where defines the position in the list that the callback function is placed. Its allowed values are:

function is placed first in the callbacks list.
function is placed last in the callbacks list.
function is removed from the callbacks list.

set-memory-exhausted-callback always first removes function from the callbacks list, and then adds it according to where. The default value of where is :first. Functions in the list are compared with equalp.

set-memory-exhausted-callback returns the callback list.

When a callback is called, Lisp already failed to map memory. This means that you must not rely on the callback to do real work. It should therefore attempt only a minimal amount of work such as clean-ups and generating debug information. It should not try to do real work.

After all the callbacks are called, the system signals an error of type storage-exhausted. The condition can be accessed using the accessors described for storage-exhausted.


set-memory-exhausted-callback is implemented only in 64-bit LispWorks. It is not relevant to the Memory Management API in 32-bit implementations.

See also


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:31:02