How do I figure out how many bytes a defclass
object has in Common Lisp?
In general a class or struct is a concept and does not occupy variable (data) space, but it does take up memory in the compiler's memory. If a class or struct has methods, those methods will take up code space, if the methods are executed (linkers tend to drop functions that are not used).
Explanation: Classes doesn't have any size, actually the size of object of the class can be defined. That is done only when an object is created and its constructor is called. 7.
The size of object of a class depends on the no. of bytes occupied by the data members of the class. }; The object of class student will occupy space of 8 bytes.
We also know that the class size is defined as the difference between the actual upper limit and actual lower of a given class interval. Therefore, the class size for the class interval 10-20 is 10.
You can't do that in portable Common Lisp.
Useful could be the function ROOM
. ROOM
prints memory statistics and with the argument T
it prints them detailed. So you may see a difference before and after some instance creations. Implementations may have specific functions, but you need to check that with the manual or with the support mailing list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With