[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

beginner question: How to find the amount of memory used to represent a symbol in common lisp?

Anoop GR

12/19/2015 12:34:00 PM

Is there a general way to do this for any object - symbol, list, hash-table, string etc ?
5 Answers

Anoop GR

12/19/2015 12:43:00 PM

0

On Saturday, December 19, 2015 at 6:04:00 PM UTC+5:30, Anoop GR wrote:
> Is there a general way to do this for any object - symbol, list, hash-table, string etc ?

say for symbol 'foo, I am looking for a way to find the following output:

'FOO name 3 byte
package 4 byte
variable 4 byte
function 4 byte
attribute list 4 byte
----------------------
total 19 byte

Paul Wallich

12/19/2015 3:53:00 PM

0

On 12/19/15 7:42 AM, Anoop GR wrote:
> On Saturday, December 19, 2015 at 6:04:00 PM UTC+5:30, Anoop GR wrote:
>> Is there a general way to do this for any object - symbol, list, hash-table, string etc ?
>
> say for symbol 'foo, I am looking for a way to find the following output:
>
> 'FOO name 3 byte
> package 4 byte
> variable 4 byte
> function 4 byte
> attribute list 4 byte
> ----------------------
> total 19 byte

Is there a reason other than curiosity that you want this information?
Most implementations document how much space different kinds of object
take up, but in the vast majority of situations that's not information
that a Lisp programmer has to keep in mind, especially a beginning one.

paul

Anoop GR

12/19/2015 5:08:00 PM

0

I needed that information while solving chapter 8 question 2 of Paul Graham's ANSI-Lisp textbook.
http://www.shido.info/lisp/pacl2_e.h...

Since it is a beginner textbook, I felt that there must be some simple built in function to find object memory
Thank you for clarifying that its not trivial

Barry Margolin

12/19/2015 8:25:00 PM

0

In article <198d0853-78e8-46a4-86cf-336024ed0c9f@googlegroups.com>,
Anoop GR <anoopemacs@gmail.com> wrote:

> Is there a general way to do this for any object - symbol, list, hash-table,
> string etc ?

You could call (room) before and after creating the object, and see how
the amounts change.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Pascal Costanza

12/19/2015 8:31:00 PM

0

On 19/12/2015 13:33, Anoop GR wrote:
> Is there a general way to do this for any object - symbol, list, hash-table, string etc ?
>

LispWorks has find-object-size. See
http://www.lispworks.com/documentation/lw70/LW/html/...

I don't know about the other CL implementations.

Pascal

--
My website: http:/...
Common Lisp Document Repository: http://cdr.eu...
Closer to MOP & ContextL: http://common-lisp.net/proje...
The views expressed are my own, and not those of my employer.