[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to ask "how big is it?"
Date: Fri, 4 Sep 87 15:05 EDT
From: Mark H. Shirley <MHS@HT.AI.MIT.EDU>
I've used the document examiner to search for this, without any luck. Does
anyone have a utility that grovels over an object in memory and reports on how
much storage it occupies? I found SYS:%STRUCTURE-TOTAL-SIZE, but this doesn't
chase pointers (e.g. to include all objects accessible in a linked
You have to define what you're looking for. If you think about it a
little, you'll see that it's not an easy problem. (For instance, how
much room does a symbol take up? 5 words? Or do you chase the pointer
to the package and find out that it points to every other symbol in the
world? Every application has to define what an "important" pointer is.)
I usually end up writing my own tool for each application. Just write a
quick function which knows how to map over your database, use a hash
table to detect circularities, and then sum up the %STRUCTURE-TOTAL-SIZE
of everything in the hash table.
Don't get fooled by the following phenomenon with lists:
(%STRUCTURE-TOTAL-SIZE (LOOP FOR I BELOW 1000 COLLECT I)) ==> 2
The reason is left as an exercise.