You can discard the functions and variables loaded by a library to
reclaim memory for other Lisp objects. To do this, use the function
unload-feature:
This command unloads the library that provided feature feature. It undefines all functions, macros, and variables defined in that library with
defconst,defvar,defun,defmacro,defsubst,define-functionanddefalias. It then restores any autoloads formerly associated with those symbols. (Loading saves these in theautoloadproperty of the symbol.)Ordinarily,
unload-featurerefuses to unload a library on which other loaded libraries depend. A library a depends on library b if a contains arequirefor b. If the optional argument force is non-nil, dependencies are ignored and you can unload any library.
The unload-feature function is written in Lisp; its actions are
based on the variable load-history.
This variable's value is an alist connecting library names with the names of functions and variables they define, the features they provide, and the features they require.
Each element is a list and describes one library. The car of the list is the name of the library, as a string. The rest of the list is composed of these kinds of objects:
- Symbols that were defined by this library.
- Lists of the form
(require .feature)indicating features that were required.- Lists of the form
(provide .feature)indicating features that were provided.The value of
load-historymay have one element whose car isnil. This element describes definitions made witheval-bufferon a buffer that is not visiting a file.
The command eval-region updates load-history, but does so
by adding the symbols defined to the element for the file being visited,
rather than replacing that element.