30.2. Saving an Image

The function (EXT:SAVEINITMEM &OPTIONAL (filename "lispinit.mem") &KEY :KEEP-GLOBAL-HANDLERS :QUIET :INIT-FUNCTION :LOCKED-PACKAGES :START-PACKAGE :EXECUTABLE :NORC :SCRIPT :DOCUMENTATION) saves the running CLISP's memory to the file filename; extension #P".mem" is recommended (when filename does not have an extension, #P".mem" extension is automatically added unless the file being created is an executable).

:QUIET

If this argument is not NIL, the startup banner and the good-bye message will be suppressed, as if by -q.

This is not recommended for interactive application delivery, please append your banner to ours (using init function) instead of replacing it.

:NORC
If this argument is not NIL, the RC file loading will be suppressed, as if by -norc.
:INIT-FUNCTION

This argument specifies a function that will be executed at startup of the saved image, before entering the standard read-eval-print loop (but after all other initialization, see Section 30.1.1, “Cradle to Grave”); thus, if you want to avoid the read-eval-print loop, you have to call EXT:EXIT at the end of the init function yourself (this does not prevent CUSTOM:*FINI-HOOKS* from being run).

See the manual for passing command line arguments to this function.

See also CUSTOM:*INIT-HOOKS* and CUSTOM:*FINI-HOOKS*.

:SCRIPT

This options determines the handling of positional arguments when the image is invoked.

This option defaults to T when init function is NIL and to NIL when init function is non-NIL.

:DOCUMENTATION

The description of what this image does, printed by the -help-image olption.

Defaults to (DOCUMENTATION init function 'FUNCTION)

:LOCKED-PACKAGES
This argument specifies the packages to lock before saving the image; this is convenient for application delivery, when you do not want your users to mess up your product. This argument defaults to CUSTOM:*SYSTEM-PACKAGE-LIST*.
:START-PACKAGE
This argument specifies the starting value of *PACKAGE* in the image being saved, and defaults to the current value of *PACKAGE*.
:KEEP-GLOBAL-HANDLERS

When non-NIL, the currently established global handlers (either with EXT:SET-GLOBAL-HANDLER or with -on-error) are inherited by the image. Defaults to NIL, so that

$ clisp -i myfile -x '(EXT:SAVEINITMEM)'

will produce an image without any global handlers inherited from the batch mode of the above command.

:EXECUTABLE
When non-NIL, the saved file will be an standalone executable. In this case, the #P".mem" extension is not added. On Win32 and Cygwin the extension #P".exe" is added instead.

You can use this memory image with the -M option. On UNIX systems, you may compress it with GNU gzip to save disk space.

Image Portability

Memory images are not portable across different platforms (in contrast with platform-independent #P".fas" files). They are not even portable across linking sets: image saved using the full linking set cannot be used with the base runtime:

$ clisp -K full -x '(EXT:SAVEINITMEM)'
$ clisp -K base -M lispinit.mem
base/lisp.run: initialization file `lispinit.mem' was not created by this version of CLISP runtime

These notes document CLISP version 2.41Last modified: 2006-10-13