Einar Karttunen <ekarttun / cs.helsinki.fi> writes:

> On 21.05 21:33, Erik Terpstra wrote:
> > 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.
> 
> A good design is important, not generating lot's of intermediate
> objects (this will be less important when the generational gc is
> included), and then iff the app eats too much memory replacing
> some critical classes by C-extensions.

That means you have to be careful not to do too much
a = "foo" + "bar"
instead
a = "#{foo}#{bar}"

But in general, the GC does a very good job in keeping memory
consumption low. Even if there were humongous amount of intermediate
objects, the OS's vm will swap those eventually unused pages to disk,
freeing RAM.

And related to your case, a DOM tree is expected to consume an ungodly
amount of memory. That's why there is a SAX parser for
memory-challanged situations.


YS.