[Openmcl-devel] memory

Alexander Repenning ralex at cs.colorado.edu
Tue Apr 13 08:07:07 PDT 2010

On Apr 13, 2010, at 4:42 AM, Gary Byers wrote:

>> And in the end in all the slots there are integers or floats..., or Strings.
>> How do I get the size of a string ? length * x.
> The SIZEOF a SIMPLE-STRING is its length * 4, + the size of a header (4 bytes
> in 32-bit CCL, 8 bytes in 64-bit CCL), rounded up to an object alignment boundary
> (8/16 bytes.)  The SIZEOF function that I mailed out yesterday should know how
> compute this value.

uvsize is a pretty handy function to compute these kinds of sizes. Overall, I prefer sizeof to be a method in order to be able to compute sizes of custom types/classes. However, Your sizeof appears to return strange results for some simple types including floats, CCL32:

? (sizeof 3.14)
;; should this not be 4

? (type-of 3.14)

In CCL64 the result is 0 because single-floats are not uvectors and the case is not handled in your cond

It should be simple to create some additional methods such as 

(defmethod sizeof ((string string)) ..

(defmethod sizeof (thing) ...

and implement then using uvsize functions


Prof. Alexander Repenning

University of Colorado
Computer Science Department
Boulder, CO 80309-430

vCard: http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20100413/65b7b6e2/attachment.htm>

More information about the Openmcl-devel mailing list