All Manuals > LispWorks® User Guide and Reference Manual > 37 The HCL Package

find-object-size Function

Summary

Returns the size in bytes of the representation of any Lisp object.

Package

hcl

Signature

find-object-size object => size

Arguments
object
Any Common Lisp form.
Values
size
An integer.
Description

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.

Examples
(hcl:find-object-size
 (make-string 1000 :initial-element #\A
              :element-type 'base-char))
=>
1012
See also

room
total-allocation


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:35