How big is the class in memory?

How do I know how many bytes a defclass object defclass in Common Lisp?

+7
lisp common-lisp sbcl clisp
source share
2 answers

You cannot do this in portable Common Lisp.

The ROOM function may be useful. ROOM prints memory statistics, and with argument T it prints them in detail. Thus, you can see the difference before and after some instance creation. Implementations may have certain functions, but you need to check this using the manual or the support mailing list.

+3
source share

In addition to Rainer's answer, here is the answer for CLISP: macro EXT:TIMES

 (defclass c () ((x) (y) (z))) (ext:times (make-instance 'c)) Permanent Temporary Class instances bytes instances bytes ----- --------- --------- --------- --------- C 1 48 0 0 ----- --------- --------- --------- --------- Total 1 48 0 0 Real time: 1.4E-5 sec. Run time: 0.0 sec. Space: 48 Bytes #<C #x000333CF2AA0> 

NB: if you evaluate defclass at the prompt, it does not compile, so times will report some down in addition to c .

+3
source share

All Articles