Perlis quipped, "A Lisp programmer knows the value of everything, but
the cost of nothing."
With this is mind, is there a way (even if implementation dependent) of
querying the amount of memory used by an object? FWIW, I'm using SBCL.
In article <··························@stablecross.com>,
····@stablecross.com (Bob Felts) wrote:
> Perlis quipped, "A Lisp programmer knows the value of everything, but
> the cost of nothing."
>
> With this is mind, is there a way (even if implementation dependent) of
> querying the amount of memory used by an object? FWIW, I'm using SBCL.
The implementation documentation may provide details of how much memory
is used by each type of object.
You can also use the ROOM function. Run it before and after allocating
the object. You should probably also run it twice in a row with nothing
in between -- the function itself may cons, and this will give you a
baseline to subtract out.
--
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***
Barry Margolin <······@alum.mit.edu> wrote:
> In article <··························@stablecross.com>,
> ····@stablecross.com (Bob Felts) wrote:
>
> > Perlis quipped, "A Lisp programmer knows the value of everything, but
> > the cost of nothing."
> >
> > With this is mind, is there a way (even if implementation dependent) of
> > querying the amount of memory used by an object? FWIW, I'm using SBCL.
>
> The implementation documentation may provide details of how much memory
> is used by each type of object.
>
> You can also use the ROOM function. Run it before and after allocating
> the object. You should probably also run it twice in a row with nothing
> in between -- the function itself may cons, and this will give you a
> baseline to subtract out.
Thanks, Barry. This will help satisfy my curiosity.
Barry Margolin <······@alum.mit.edu> wrote:
+---------------
| You can also use the ROOM function. ...
+---------------
Also be sure to try all three ANSI-defined variants,
which might give usefully-different amounts of information:
(room nil)
(room :default) ; Or simply (room)
(room t)
-Rob
-----
Rob Warnock <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
····@stablecross.com (Bob Felts) writes:
> Perlis quipped, "A Lisp programmer knows the value of everything, but
> the cost of nothing."
>
> With this is mind, is there a way (even if implementation dependent) of
> querying the amount of memory used by an object? FWIW, I'm using SBCL.
The problem is that since in lisp we have a garbage collector, we
don't have to think about freeing memory, so we can easily share parts
of our data structures.
The space cost is then shared amongst several datastructures, thus
divided by the number of use. Asymptotically, it's 0.
--
__Pascal Bourguignon__ http://www.informatimago.com/
"Logiciels libres : nourris au code source sans farine animale."
Pascal Bourguignon <···@informatimago.com> wrote:
> ····@stablecross.com (Bob Felts) writes:
>
> > Perlis quipped, "A Lisp programmer knows the value of everything, but
> > the cost of nothing."
> >
> > With this is mind, is there a way (even if implementation dependent) of
> > querying the amount of memory used by an object? FWIW, I'm using SBCL.
>
> The problem is that since in lisp we have a garbage collector, we
> don't have to think about freeing memory, so we can easily share parts
> of our data structures.
>
> The space cost is then shared amongst several datastructures, thus
> divided by the number of use. Asymptotically, it's 0.
But practically is another story. In my case, I'm creating a list which
holds the contents of a file (e.g. 36MB) and I'm curious about how
implementation choices affect memory use.
Bob Felts wrote:
> Pascal Bourguignon <···@informatimago.com> wrote:
>
>> ····@stablecross.com (Bob Felts) writes:
>>
>>> Perlis quipped, "A Lisp programmer knows the value of everything, but
>>> the cost of nothing."
>>>
>>> With this is mind, is there a way (even if implementation dependent) of
>>> querying the amount of memory used by an object? FWIW, I'm using SBCL.
>> The problem is that since in lisp we have a garbage collector, we
>> don't have to think about freeing memory, so we can easily share parts
>> of our data structures.
>>
>> The space cost is then shared amongst several datastructures, thus
>> divided by the number of use. Asymptotically, it's 0.
>
> But practically is another story. In my case, I'm creating a list which
> holds the contents of a file (e.g. 36MB) and I'm curious about how
> implementation choices affect memory use.
For things which use large chunks of memory in sbcl on linux, I call
(gc :full t) and then check the unix top command -- before and after
allocating or freeing memory in lisp. This reliably detects memory
leaks both inside and outside lisp (e.g. in CFFI interfaces). Others
already pointed you to ROOM; usage is generally similar to top, but it
stays inside lisp.
For a somewhat rougher guesstimate, sbcl's implementation of TIME can
be helpful -- though it includes memory that is gc'd.
CL-USER> (time (progn (make-array '(100 200))
nil))
Evaluation took:
0.0 seconds of real time
0.0 seconds of user run time
0.0 seconds of system run time
0 calls to %EVAL
0 page faults and
160,016 bytes consed.
NIL
- Daniel
On Sat, 12 Apr 2008 22:00:46 -0400, ····@stablecross.com (Bob Felts) wrote:
> With this is mind, is there a way (even if implementation dependent)
> of querying the amount of memory used by an object?
That's implementation-dependent.
http://www.lispworks.com/documentation/lw51/LWRM/html/lwref-211.htm
Edi.
--
European Common Lisp Meeting, Amsterdam, April 19/20, 2008
http://weitz.de/eclm2008/
Real email: (replace (subseq ·········@agharta.de" 5) "edi")
On Apr 13, 4:38 am, Edi Weitz <········@agharta.de> wrote:
> On Sat, 12 Apr 2008 22:00:46 -0400, ····@stablecross.com (Bob Felts) wrote:
> > With this is mind, is there a way (even if implementation dependent)
> > of querying the amount of memory used by an object?
>
> That's implementation-dependent.
>
> http://www.lispworks.com/documentation/lw51/LWRM/html/lwref-211.htm
>
> Edi.
>
> --
>
> European Common Lisp Meeting, Amsterdam, April 19/20, 2008
>
> http://weitz.de/eclm2008/
>
> Real email: (replace (subseq ·········@agharta.de" 5) "edi")
I tried to made a find-object-size in SBCL looking at the source of
room. I founded the function sb-vm::map-allocated-objects which inform
the the memory used by all the objects. I can't figure out how to get
the pointers of a specific object tree and sum the memory usage of
those.
Edi Weitz <········@agharta.de> wrote:
> On Sat, 12 Apr 2008 22:00:46 -0400, ····@stablecross.com (Bob Felts) wrote:
>
> > With this is mind, is there a way (even if implementation dependent)
> > of querying the amount of memory used by an object?
>
> That's implementation-dependent.
>
> http://www.lispworks.com/documentation/lw51/LWRM/html/lwref-211.htm
>
One of these days I'll have $1500 to spend on LW. I've been itching for
some time, now...