[plt-scheme] sizeof
Thanks, Robby and Synx, for your feedback. I think I'm sorted now. Comments below:
Synx wrote:
> Dave Gurnell wrote:
>> Is there a simple way of estimating the number of bytes of RAM that a particular piece of data is occupying?
>
> That would be simple, until you consider the case of some joker making a
> piece of data as (list (current-custodian)). What's the size of that?
> Your entire memory! The problem is that structured data doesn't actually
> contain the data, only a pointer to that data. Determining the size of
> the pointers isn't often useful, but determining the size of the data
> risks that your data structures end up encompassing the entire computer,
> since though a structure can't easily hold everything, it can easily
> point to everything.
Understood. Fortunately I'm not trying to solve anything that general, although that explains why there aren't built-in procedures to do the job.
My data is pretty much the simple primitives, lists, vectors, hashes, structs and objects. I've adapted my simple memoized breadth-first algorithm with Robby's figures and that'll probably do me for now.
> (sizeof (make-thingy (current-custodian) (current-continuation-marks)
> (current-eventspace)) => ?
>
> It would be much better for you to just measure the memory before and
> afterwards [...]
Yes. We have some logging in place like this to measure the minute-by-minute memory consumption of the web server. However, I need a little more detail to try and optimise specific bits of application. Hopefully a combined approach (minute-by-minute recording of current-memory-use combined with page-by-page estimates of the size of specific data structures) will do the job.
-- Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100106/6bea0383/attachment.html>