From: Hal Fulton Date: 2005-10-05T13:20:49+09:00 Subject: Re: Monitoring total memory usage? Andrew Backer wrote: > Hello, > > I need to monitor the memory usage of a ruby script, and I would like > to see if I can do it with within the program itself, or from a monitor > script also in ruby. Is there a way to do this? Using school as an > excuse to learn ruby, and this is one part of it. Hmm. The GC must know something about this, but I don't think it exposes it. Maybe it should? Or maybe it's possible to make a system call or something? Of course, a little Heisenberg gets thrown in... Failing that, you *might* be able to traverse object space somehow and add up the memory usage. I wouldn't want to do it. > just thought i'd throw my 2c in > 1) no true reference parameters is a pain (how do i write a swap!) > 2) a,b = b,a is the coolest thing ( oh, thats how! ) :) Yes. You can also pass in arrays (whose contents can be changed). I don't recommend using arrays or any other such thing as though it were a real reference parameter, though. Usually when I (start to) want ref params, I just return multiple values from the method instead. > 3) array wrapping can be an error and is not to be allowed sometimes > 4) (can I turn it off?) Wrapping? > 5) it is so easy to extend built in classes! ( added an array.resize() Exercise normal caution when using this feature. :) > 6) why is there no serious formatting support built into the objects? I > guess I'm spoiled by C# now. Formatting? You mean like in output? Do you know about: p object and require 'pp' pp object ? Cheers, Hal