Is there a way to find out how much memory is used by an instance of a class or basic data types in general?
I have a toy webframework in cl that creates and manages web pages with instances of classes that represent the html tags and their properties, and as they are supposed to make an html page, they have children in a slot called children. so I was thinking how much a user’s session will cost the server if I take this approach. Thanks.
As far as I know, there is nothing like this for arbitrary objects in the standard, but there are implementation-dependent solutions, like
ccl:object-direct-sizein CCL:However, be aware that whether these do what you want depends on what you mean by “size”, since those functions usually don’t include the size of the components the object references. You can also run the GC, initialize a few objects and compare
room‘s output before and afterwards.Also, note that
timeusually includes allocation information:Maybe you could try something like this (untested, really just a quick hack):
For example: