Yohanes Santoso wrote: > Erik Terpstra <erik / solidcode.net> writes: > >>Is there some method that tells me how much memory a certain object >>consumes? >> >>For example the size of: ['Hello world!', 345, [2, 9.43553]] > > String: 4 long + 1 pointer + the length of your string in bytes * 1 char > Fixnum: 2 long + 1 int > Array: 4 long + 1 pointer + the length of your array * 1 pointer > > This is all my guess from scanning ruby.h. Perhaps wrong, but should > be around the ballpark. Hmmm thanks, but I'm affraid that doesn't really help me when I want to know the memory consumption of a DOM tree for example. In lower level languages you usually know if your program is efficient with available memory because you allocate it yourself. I find it very hard to make memory-efficient programs in Ruby when they become larger and more complex. Any thoughts? Erik.