[Openmcl-devel] calcultaing memory use.

Gary Byers gb at clozure.com
Mon Nov 15 05:38:58 PST 2004



On Mon, 15 Nov 2004, Marco Baringer wrote:

>
> i'm attempting to profile ucw's memory use and i've found the need to
> write a sizeof-ish function. if i can figure out how much cretain
> primative objects consume than writing a function to traverse objects
> shouldn't be too hard. so, how many bytes are needed for a cons cell?
> a hashtables' key and value? a clos instance? a closure?
>

I wrote a first approximation of a memory profiler last spring; see

<http://clozure.com/mailman/htdig/openmcl-devel/2004-March/001475.html>.

I didn't try very hard at the time to account for space that's reserved
for per-thread consing but not yet allocated; I don't think that it'd
be as hard to do this as I thought it was at the time.

> of course, i'm assuming these question are answerablee, and maybe
> they're not, or maybe there's a much simpler way to go about it (i'm
> on osx 10.2 so i can't use the profiler).
>

Determining how much memory a given lisp object takes up is fairly
simple: conses are a pair of 32-bit words, everything else has a
32-bit header on the front of it and everything is aligned on a
doubleword boundary.  (See the code attached to the message cited
above for details.)

Determining "how much memory is uniquely referenced by some object"
is much harder (and sometimes much more interesting.)



More information about the Openmcl-devel mailing list