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 storage currently used to represent the object. If the object takes up no heap storage (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 string of 10 characters occupies more than 10 bytes of storage.

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
USER 37 > (hcl:find-object-size
                    (make-string 1000 :initial-element #\A)) 
1012
See also
room
total-allocation

LispWorks Reference Manual - 23 Jul 2004

NextPrevUpTopContentsIndex