From: Robert Klemme Date: 2008-06-19T15:28:50+09:00 Subject: Re: Can I find out the memory used by an object? On 18.06.2008 19:46, David Masover wrote: > On Wednesday 18 June 2008 04:43:50 Robert Klemme wrote: > >> This is why tools like "ls" and "du" are >> useful in practice because you can be pretty sure, that only a >> negligible portion of disk usage is counted more than once. But the >> topology of an object graph might look totally different, i.e. more >> interconnected. > > Noting that du won't count hardlink'd files more than once, it seems your > point here is that such a tool would be less efficient in Ruby than it is for > filesystems? Exactly. They would work but the output would be less meaningful or harder to interpret. In other words if you do a "du" in the filesystem you know pretty good which folders or files you'll have to remove to get more space on your device whereas that would not be as obvious for a similar Ruby tool. >> Then there are different types of links - soft links and hard links. >> This gives file system utilities a means to ignore paths. Usually >> soft links are much more often used than hard links (in my personal >> experience anyways) while hard links more closely resemble object >> references in Ruby. > > However, filesystem utilities can be made to follow softlinks. Also, I'd argue > that the choice to use softlinks over hardlinks has nothing to do with making > life easier for du, and everything to do with the relative semantics of > actual usage here. Absolutely. The point was simply that there are different types of links which can be instrumented by the user to control what tools like "ls" will output. So the user can state "follow soft links" or "don't follow soft links" which is a distinction you cannot make with Ruby's object references. And this distinction can be used to determine the scope of objects (i.e. files and directories) that are reached by those unix tools. Since you do not have that in Ruby land you have less control. Kind regards robert