<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
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.<br>
<br>
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.<br>
<br>
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 <i>didn't</i>
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.<br>
<br>
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.<br>
<br>
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.<br>
<br>
<div class="moz-signature">-- <br>
<div style="background-color: white; color: black;"> <span
class="Apple-style-span"
style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span
class="Apple-style-span"
style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span
class="Apple-style-span"
style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span
class="Apple-style-span"
style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<div>
<p style="margin: 0px;"><font class="Apple-style-span" size="6"><span
class="Apple-style-span" style="font-size: 19px;"><b>Joe Khoobyar<br>
</b></span></font></p>
<p style="margin: 0px;"><font class="Apple-style-span" color="#565757">Chief
Technical Officer & Lead Developer</font></p>
<p style="margin: 0px 0px 12px;"><span class="Apple-style-span"
style="color: rgb(47, 82, 16); font-size: 19px; font-weight: bold;">CollectiveX</span>
<font
style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 119, 68);"
color="#007744" face="Helvetica" size="4"> - <i>Groups that work!</i></font></p>
<p style="margin: 0px;"><font
style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(86, 87, 87);"
color="#565757" face="Helvetica" size="3">mobile: 585.245.2902 </font></p>
<p style="margin: 0px;"><font
style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(86, 87, 87);"
color="#565757" face="Helvetica" size="3">email: </font><font
style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 31, 230);"
color="#001fe6" face="Helvetica" size="3"><a
href="mailto:joe@collectivex.com">joe@collectivex.com</a></font></p>
<p style="margin: 0px;"><font
style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(86, 87, 87);"
color="#565757" face="Helvetica" size="3">web: </font><font
style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 31, 230);"
color="#001fe6" face="Helvetica" size="3"><a
href="http://www.collectivex.com/">www.collectivex.com</a> <a
href="http://www.groupsites.com/">www.groupsites.com</a></font><br>
<br>
<font
style="font-family: Helvetica; font-style: italic; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(108, 108, 108);"
color="#565757" face="Helvetica" size="3"> The third-rate mind is only
happy when it is thinking with the majority.<br>
The second-rate mind is only happy when it is thinking with the
minority.<br>
The first-rate mind is only happy when it is thinking.<br>
<br>
— A.A. Milne</font></p>
</div>
</span></span></span></span> </div>
</div>
</body>
</html>