From: Kazuhiko <kaz...@fd...> - 2009-08-31 20:02:36
|
かずひこです。 tDiary on Ruby-1.9 with FCGIでメモリ爆発する件で、プラグイン内でキモい evalをしているプラグイン (*) があると、ObjectSpace内に回収されないオブ ジェクトが増えて行くことが分かりました。 http://redmine.ruby-lang.org/issues/show/2024 (*) キモいevalの例 navi_user.rb: eval( <<MODIFY_CLASS, TOPLEVEL_BINDING ) module TDiary class TDiaryMonthWithoutFilter < TDiaryMonth def referer_filter(referer); end end end MODIFY_CLASS たぶん近いうちにRuby 1.9側で修正してくれる気がしますが、それはそれとし て、ここで、ただのmodule定義ではなく、キモいevalをしている理由って何でし たっけ? また、何らかの理由があるとしても、オフィシャルプラグインで必要とされてい る機能で、特に害をあたえなさそうなものは、本体(tdiary.rb)側にとりこん でしまいませんか? tdiary.rbの定義は、一度requireされればあとは評価されることが無いのに対 し、プラグインはアクセスごとに定義されるので、パフォーマンス的に無駄です から。 というわけで、以下、キモいevalのあるプラグイン一覧。 counter.rb disp_referrer.rb makelirs.rb makerss.rb navi_user.rb pb-show.rb recent_list.rb tb-show.rb title_tag.rb よろしくお願いします。 かずひこ |