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

NextPrevUpTopContentsIndex

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

The result is an integer which is the number of bytes of heap memory currently used to represent the object. If the 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".

The size of a heap object 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.

Description

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.

Example
(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 - 20 Sep 2017

NextPrevUpTopContentsIndex