Returns the size in bytes of the representation of any Lisp object.
hcl
find-object-size object => size
object⇩ |
Any Common Lisp form. |
size⇩ |
An integer. |
The function find-object-size
returns the size in bytes of object.
size is the number of bytes of heap memory currently used to represent object. If object takes up no heap memory (fixnum or character), then 0 is returned. Such objects are represented by an immediate value held in a single machine "word".
size includes hidden space required to hold type and other information; for instance, a base-string of 10 1-byte characters occupies more than 10 bytes of memory.
Certain Common Lisp objects are not represented by a single heap object; for instance, using find-object-size
on a hash-table is misleading as the function returns the size of the hash-table descriptor, rather than the total of the descriptor and the hash-table-array. General vectors and arrays also have this property. All symbols are of the same size, since the print name is not part of a symbol object.
(hcl:find-object-size (make-string 1000 :initial-element #\A :element-type 'base-char)) => 1012
LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:35