[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

storage commands?



    Date: Wed, 6 May 1992 09:18 EDT
    From: smith@icat.larc.nasa.gov (Steven L. Smith)

    How can I find out the amount of storage (words) required by a variable.
    For example, if a symbol is bound to a list, I would like to known
    the amount of internal memory require to store that list and its
    contents. I'm working with a XL1200.

The function SYS:%STRUCTURE-TOTAL-SIZE will tell you the amount of
storage used by an individual object.  However, this doesn't include the
storage used by all the objects it references.  For instance, for a cons
it will just return 2 (for a list, it may return anthing between the
size of a cons or the number of elements in the list, depending on how
much CDR-coding is used in the list).

If you want to know the total size of a list and everything it
references, you'll have to write a recursive function that adds it all
up.  It will have to know how to descend into every type of object, or
at least the ones you care about.  It should probably also have
circularity detection, so that it doesn't recurse infinitely on
recursive data structures.

You can run the routine that allocates the list and its contents within
the TIME macro.  This reports on the amount of consing that took place.
This won't be completely accurate because it will also include consing
from background processes.  If your routine doesn't take long to run you
can wrap the call in PROCESS:WITH-NO-OTHER-PROCESSES to prevent
background processes from running during that time.

                                                barmar