I'm curious about this. The author seems to talk about "processes" and whole buffers that hang around past their welcome. I'm hearing in this article that Emacs elisp can start a process, (this example uses system's ping?), but then the process stays live (where? on emacs' stack/heap?) until his finalize frees it. A simpler question might be, how can you intentionally free up anything else in a running (one namespace) Emacs session? For example, with org-mode's Library of Babel, "ingesting" a file of code blocks tangles said code, then with org-sbe attaches desired code blocks (by name) to a org-babel-library-of-babel a live variable. All right, I can set it to nil or redo it manually, but what about functions? Do you just set a function symbol to nil in your session? How can I get an overview of what's "live?"

1 Answer 1


A live object is one that you can reach by following pointers from other live objects. Functions and variables are live because they are reachable from the global list of definitions. Setting a definition to nil means that it no longer points to the value it once did, potentially creating garbage. The GC will collect that garbage in fairly short order. As for processes, it's true that they're never garbage collected. All Emacs has is the file handles to them; since they're external they can't participate in the garbage collection. This is rarely a problem; all the modes that create them either intend for them to stick around long-term (slime, tramp, erc, etc) or clean them up when they're done with them (compile, flymake, etc).

In practice, users of Emacs largely ignore these issues. The garbage collector just works, and although Emacs has a reputation for being a memory hog it uses a trivial amount of memory on today's systems. Clearing one variable is unlikely to free up more than a few bytes, and just causes you to lose information you might have had a use for later. Undefining functions is similar; if you know you're never going to use it you're better off not loading the library instead. That saves you startup time, which is a more valuable commodity than a few dozen bytes of memory.

  • Is there any way to know what exactly is "loaded" and what resources are being used? I'm guessing Emacs would not allow a second loading of a function to occupy two spots.
    – 147pm
    Commented Nov 28, 2015 at 15:13
  • You can ask your OS how much memory a program is using. At the moment Emacs is using 88MB of my memory; not exactly a lot. And you're correct; if you require the same module twice it only gets loaded once. This happens all the time, in fact, as you might require modules A and B which both require module C.
    – db48x
    Commented Nov 28, 2015 at 20:48
  • Ha! The proverbial 80 megs (Em).
    – 147pm
    Commented Nov 28, 2015 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.