Q: how does one determine how much memory an arbitrary lisp object is consuming?

Example use case: I've got a hash table holding lists of strings. I'm curious about how much memory it's using.

  • I think that the problem is in determining what to count. Just the object fields (but not the values in those fields)? Do methods count? With "simple" objects like the hash-table, you could make an educated guess: say, count the total length of the keys, count the number of keys and multiply it with log base two and a size of a key - this would give you roughly the size of the memory used to store the keys, but as to the values - depends on what you count.
    – wvxvw
    May 11, 2015 at 9:18
  • See also emacs.stackexchange.com/a/64776/15748
    – Basil
    Oct 5, 2021 at 13:42

1 Answer 1


How to determine the size? By looking at the C source code whee those objects are defined (e.g. src/lisp.h).

IIRC in the case of a hash-table, you should count more or less 6 words (32 or 64bit, depending on your system) per element in the hash-table.

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.