A few weeks ago, Chris and I fixed a significant memory leak in
libxml-ruby. However, we still observed significant memory usage when
running a simple test case.
Since then, I've intended to try and decrease the memory usage.
Finally, this weekend, I made a small but significant change which
decreases memory usage an order of magnitude less than it was before.
Revision 783 in subversion applies this change. With this change,
test08.rb holds about 13 MB on a Mac, where it held over 120 MB before.
We are simply using libxml2's memory management hooks to direct it's
alloc/free functions and related functions to ruby's versions of those
functions. What I originally planned (which is why I'm using
xmlGcMemSetup) was to direct what libxml2 calls "atomic" memory
allocations to the version of the ruby's allocator which is able to run
the garbage collector. Of course, what I shortly discovered was that
there was apparently no version of the ruby allocator that /didn't/
attempt to run the garbage collector. That considered, I can probably
safely change this to use xmlMemSetup without any change in behavior.
Honestly, though, it doesn't matter as far as the logic is concerned.
Basically what this does is have both libxml2 and ruby use the same
allocator and allow ruby to run it's GC even in response to libxml2
allocations which keeps memory usage down much more easily. I'm already
running this on all of our production servers and it yielded instant
benefits.
Just wondering: does anyone have any feedback on this change or on this
subject? FYI: I've been running it on 32-bit ruby on OS X Leopard and
on several 64-bit UNIX instances for half a week now.
--
*Joe Khoobyar
*
Chief Technical Officer & Lead Developer
CollectiveX - /Groups that work!/
mobile: 585.245.2902
email: j...@collectivex.com <mailto:j...@collectivex.com>
web: www.collectivex.com
<http://www.collectivex.com/> www.groupsites.com
<http://www.groupsites.com/>
The third-rate mind is only happy when it is thinking with the majority.
The second-rate mind is only happy when it is thinking with the minority.
The first-rate mind is only happy when it is thinking.
--- A.A. Milne
_______________________________________________
libxml-devel mailing list
libxml-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel