[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Size-of instance
- To: info-mcl@digitool.com
- Subject: Re: Size-of instance
- From: Shannon V Spires <svspire@somnet.sandia.gov>
- Date: Thu, 18 May 1995 09:24:42 -0600 (MDT)
- Cc: svspire@somnet.sandia.gov (Shannon V Spires), missing@inch.com
- In-reply-to: <199505180500.BAA00958@digitool.com> from "info-mcl-digest-request@digitool.com" at May 18, 95 01:00:04 am
- Sender: owner-info-mcl@digitool.com
Ken Tilton wrote:
> To Digitool--how about a size-of function?
Here's a way to tell the size, in bytes, of a CLOS
instance. It should be as accurate as Bill's meter-consing
macro, and it has the additional advantage of being able
to operate on an instance after it's created. Bear in
mind, however, that it's not portable and it won't be
accurate for forwarded instances (instances whose class
definitions have changed). Perhaps someone can improve
this to deal better with forwarded instances. (For
forwarded instances, should it show the total of the
old and the new instances or just the new one???)
The minimum size of a CLOS instance is 16 bytes: 8 for the pointer
to the class wrapper and 8 for space for a forwarding pointer.
See the documentation for uvsize etc. in your MCL manual
for more info.
(defmethod sizeof ((me standard-object))
(* 8 (uvsize me)))
#|
(defclass foo () (slot1 slot2))
(meter-consing (make-instance 'foo)) ; you may need to do this twice to
; get things initialized
-> Consed 24 bytes
(meter-consing (setf f (make-instance 'foo)))
-> Consed 24 bytes
(sizeof f)
-> 24
|#
--
Shannon Spires
svspire@sandia.gov