3

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 '15 at 9:18
2

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, privacy policy and cookie policy

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