[Openmcl-devel] memory

Gail Zacharias gz at clozure.com
Mon Apr 12 16:39:56 UTC 2010


At 4/12/2010 11:00 AM, Daniel Weinreb wrote:

>Gary Byers wrote:
>>
>>When people ask questions like this, they usually means something
>>like "what's the total size of this object, plus the size of all things that
>>it transitively and uniquely references ?"
>>
>>Another way of asking that is to ask "if the object in question became
>>garbage, how
>>much memory would be freed by the GC ?"
>>
>I'm not sure it's exactly that.  Suppose you have a hash
>table with two elements, A and B. A is only reachable through
>the hash table; B is reachable in other ways.
>
>If there were a size-of-this-object function applied to the hash table,
>I don't think you'd want it to include A, even though A would become
>garbage if the hash table became garbage.

You would want to include A if the hash table was the root of your 
data, i.e. if your primary object (e.g. a musical composition) 
happens to be represented by a hash table.  If the hash table is 
_not_ a root, then both A and the hash table itself would be 
attributed to something that is.


>But I agree with your fundamental point.  If someone asks
>"what is the size of this object", "object" can mean more
>than one thing depending on the level of abstraction.
>In the case of a hash table, probably the caller "means"
>to include all the pieces that make up a hash table,
>which might be many "objects" in the low-level sense,
>since hash tables can be implemented as data structures
>with many low-level objects.
>
>Lisp could know about hash tables specially, but
>what if the user, or library being used by the user,
>has objects in the high-level sense?  They'd have
>to provide some kind of method to say "here's how
>to measure my size" that would say which references
>to follow and where to stop following references.
>
>-- Dan
>
>>
>>
>>(let* ((obj (make-instance ...)))
>>   (gc)
>>   (let* ((with-obj (%precise-size-of-allocated-memory-at-the-moment)))
>>     (setq obj nil)
>>     (gc)
>>     (let* ((without-obj (%precise-size-of-allocated-memory-at-the-moment)))
>>       (- with-obj without-obj))))
>>
>>There's no such function as the one that I'm calling
>>%PRECISE-SIZE-OF-ALLOCATED-MEMORY-AT-THE-MOMENT; it's very hard to measure
>>this in CCL (because of threads and because of other issues.)  We're also
>>assuming that OBJ is the only thing that becomes garbage between the two
>>GCs, and we're assuming that that object isn't sitting in some machine
>>register even after we set the variable OBJ to NIL.  Neither of those
>>assumptions is valid.
>>
>>I don't want to say that there's no reliable way to answer this question in
>>general, but it's much, much harder to answer than it might appear to be at
>>first glance.
>>
>>There are some heap-analysis utilities described at
>><http://trac.clozure.com/ccl/wiki/MemoryUtils> (some of them are currently
>>x8664-Linux-specific); none of them try to answer this question, but they
>>do try to answer some similar questions.
>>
>>
>>
>>--On April 11, 2010 4:50:23 PM +0200 Joakim Sandgren
>><mailto:joakim at joakimsandgren.com><joakim at joakimsandgren.com> wrote:
>>
>>
>>>
>>>Hi,
>>>Are there a way to see how big in Kb  or bytes a clos object is ?
>>>
>>>
>>>sincerely
>>>joakim
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>Joakim Sandgren
>>>joakim sandgren musik
>>>42, rue de Maubeuge
>>>75009 Paris
>>>France
>>>+33 (0)1 45 26 43 90
>>><mailto:info at joakimsandgren.com>info at joakimsandgren.com
>>>http://www.joakimsandgren.com
>>>
>>
>>
>>
>>
>>
>>_______________________________________________
>>Openmcl-devel mailing list
>><mailto:Openmcl-devel at clozure.com>Openmcl-devel at clozure.com
>>http://clozure.com/mailman/listinfo/openmcl-devel
>>
>_______________________________________________
>Openmcl-devel mailing list
>Openmcl-devel at clozure.com
>http://clozure.com/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list