troff uses over 500MB of memory when generating the html documentation for libX11-1.3.2, causing the OOM killer to trigger on one of my systems. Upstream has implemented a partial fix, but that fix introduces a double-free and other even nastier problems. The patches I have attached include the upstream fix, a fix for that fix and several fixes for the most important memory leaks in troff. I've sent these fixes to the upstream mailing list as well. Be sure to enable the new doc USE flag to libX11 if you want to reproduce this.
Created attachment 210881 [details, diff] Fixed upstream patch
Created attachment 210883 [details, diff] Fix for "definitely lost" memleaks reported by valgrind
should be fixed with groff-1.20.1-r3. i grabbed the fixes from the upstream cvs.