Ruby-GNOME2におけるGC問題

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Ruby-GNOME2におけるGC問題 - Presentation Transcript

    1. Ruby-GNOME2 における GC 問題 酒井 政裕 元? Ruby-GNOME2 開発者
    2. 背景
      • 参照カウント
        • gtk+ など、使っているライブラリは多い
        • 循環参照は NG
      • マークアンドスイープ
        • Ruby の GC はこれ
        • 循環参照も OK
      • 拡張ライブラリでは連携が必要
        • しかし両方にまたがる循環参照は NG
    3. 簡単な具体例
      • def hello_button
      • b = Button.new
      • b.signal_connect(“clicked”){
      • puts “Hello World”
      • }
      • b
      • end
      • hello_button()
      このボタンは GC 出来ない
    4. 何が起こっているか? – 参照関係 GtkButton GClosure Button Proc ruby 側 gtk 側 循環参照 変数 b
    5. rubyのGCからどう見えるか GtkButton GClosure Button Proc ruby 側 gtk 側 gtk 側 : (1) 参照関係が見えない (2) GC の root になる
    6. 対処法
      • 原理的な方法
        • ruby or gtk+ に手を入れる
        • 例 ) gtk 側の参照関係をトラバースする API
        • たぶん非現実的
      • Ruby-GNOME2 では
        • 両方に跨る循環を 無理やり 無くして対処
        • 須藤さんのアイディア
        • 具体的には……
    7. Ruby-GNOME2 では (1): gtk 側から ruby 側への参照を無くす GtkButton GClosure Button Proc ruby 側 gtk 側 この参照を削除し 循環を無くす
    8. Ruby-GNOME2 では (2): gtk 側の参照関係を ruby 側で模倣 GtkButton GClosure Button Proc ruby 側 gtk 側 GC からの保護に必要
    9. Ruby-GNOME2では (3)
      • 両方に跨る循環を ruby 側だけの循環に
      • これならば ruby は GC できる !
      • 問題点
        • 実際には模倣は原理的なものではなく、ただの 近似 。
        • gtk が保障していない条件に依存。 現在の gtk の範囲では問題は起こらないはずだが、 それ以外ではエラーが起こる可能性も……
        • これは 「危険側に倒した」 デザイン
          • 個人的には、あまりよろしくないと思うが……
    10. おわりに
      • 今回紹介した以外のバリエーションも有り
      • 他の拡張ライブラリ
        • イベントハンドラを扱えば同様の問題は起こりうる
        • 特に他のGUIツールキットはどのように対処しているのか?
      • GCって難しいねぇ
      • 世界が単一のオブジェクトシステムで統一されれば良いのに
    SlideShare Zeitgeist 2009

    + Masahiro SakaiMasahiro Sakai Nominate

    custom

    277 views, 0 favs, 1 embeds more stats

    Ruby-GNOME2におけるGC問題

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 277
      • 275 on SlideShare
      • 2 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 0
    Most viewed embeds
    • 2 views on http://www.tom.sfc.keio.ac.jp

    more

    All embeds
    • 2 views on http://www.tom.sfc.keio.ac.jp

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories