[ruby-gnome2] general memory problems with ruby-gnome2?

Discussion in 'Ruby' started by David Espada, Jun 30, 2004.

  1. David Espada

    David Espada Guest

    Hi all.

    This is not a message about a concrete error. I need your advice in
    order to explore memory problems with an application using ruby1.8
    and ruby-gnome2 in Linux Debian Sid.

    My application is relatively complex. It generates dinamic windows
    form represnting data in postgres database. Each window has a
    notebook with various pages, and each page has a treeview
    representing detail of data.

    So, in diary work, program creates and destroys windows continually.

    When I worked with ruby-gnome1, there was no memory problems and
    program was speedy. But now, with same estructure of data
    presentation and using ruby-gnome2, memory use grows without limit
    until machine begins to use virtual memory in great amounts, slowing
    work.

    I destroy each window properly when it is closed, but don't know if
    that is enought. Might I do anything more in order to reduce memory
    usage?

    Thanks for your advice. Greets.

    David
    David Espada, Jun 30, 2004
    #1
    1. Advertising

  2. David,

    Without looking at the code, there are a couple of things I might recommend:

    First, as a simple debugging tool, add a log of the GObjects left in
    memory after certain major operations with something like the
    following:
    if DEBUG
    GC.start
    ObjectSpace.each_object(GLib::Object) {|o|
    STDERR.puts "#{o.inspect} :: #{o.ref_count}
    }
    end

    If that list just keeps growing each time, even though you're trying
    to free any old window handles, then the refcounts on the widgets
    you're creating aren't getting to zero. I'd look for any persistent
    (as in lasts as long as the program runs) datastructure (like a hash
    of window references, or instance variables of a wrapper class) that
    could be holding on to references.

    Otherwise, if you just can't seem to track down the refs or it turns
    out that the Ruby-GNOME2 bindings aren't letting them get GC'd
    properly, then you might want to try re-using window and widget
    handles, rather than destroying and recreating them each time.
    Top-level windows, TreeModel/View/Store instances, etc., are probably
    "heavy" enough to be worth keeping around and re-populating with new
    child widgets and data as needed.

    Hope that helps,

    Lennon

    On Wed, 30 Jun 2004 18:02:57 +0900, David Espada
    <> wrote:
    > Hi all.
    >
    > This is not a message about a concrete error. I need your advice in
    > order to explore memory problems with an application using ruby1.8
    > and ruby-gnome2 in Linux Debian Sid.
    >
    > My application is relatively complex. It generates dinamic windows
    > form represnting data in postgres database. Each window has a
    > notebook with various pages, and each page has a treeview
    > representing detail of data.
    >
    > So, in diary work, program creates and destroys windows continually.
    >
    > When I worked with ruby-gnome1, there was no memory problems and
    > program was speedy. But now, with same estructure of data
    > presentation and using ruby-gnome2, memory use grows without limit
    > until machine begins to use virtual memory in great amounts, slowing
    > work.
    >
    > I destroy each window properly when it is closed, but don't know if
    > that is enought. Might I do anything more in order to reduce memory
    > usage?
    >
    > Thanks for your advice. Greets.
    >
    > David
    >
    >
    Lennon Day-Reynolds, Jun 30, 2004
    #2
    1. Advertising

  3. David Espada

    David Espada Guest

    El miércoles 30 de junio, Lennon Day-Reynolds escribió:
    > First, as a simple debugging tool, add a log of the GObjects left in
    > memory after certain major operations with something like the
    > following:
    > if DEBUG
    > GC.start
    > ObjectSpace.each_object(GLib::Object) {|o|
    > STDERR.puts "#{o.inspect} :: #{o.ref_count}
    > }
    > end


    Good!

    I have probed many things. Now I Know where is the problem (main
    problem, at least). When I use Gtk::NoteBook in a data window, there
    is no parent for the pages of that. So, when I destroy window, pages
    with ALL their contents survive in memory until application hangs.

    If I do:

    signal_connect('destroy') do
    children.each do |c|
    c.destroy
    end
    end

    in NoteBook constructor, problem dissapears and all memory frees
    normally (or so I think).

    Thanks for your help with debugging method :)

    Greets.

    David
    David Espada, Jul 1, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laurent Sansonetti

    Ruby-GNOME2 website in French

    Laurent Sansonetti, Aug 18, 2003, in forum: Ruby
    Replies:
    0
    Views:
    79
    Laurent Sansonetti
    Aug 18, 2003
  2. Masao Mutoh

    [ANN] Ruby-GNOME2-0.7.0

    Masao Mutoh, Sep 7, 2003, in forum: Ruby
    Replies:
    5
    Views:
    110
    Aredridel
    Sep 9, 2003
  3. Laurent Sansonetti

    [ANN] #ruby-gnome2 @ irc.gnome.org

    Laurent Sansonetti, Oct 20, 2003, in forum: Ruby
    Replies:
    0
    Views:
    92
    Laurent Sansonetti
    Oct 20, 2003
  4. Masao Mutoh

    [ANN] Ruby-GNOME2-0.8.0

    Masao Mutoh, Nov 16, 2003, in forum: Ruby
    Replies:
    0
    Views:
    77
    Masao Mutoh
    Nov 16, 2003
  5. Masao Mutoh

    [ANN] Ruby-GNOME2-0.8.1

    Masao Mutoh, Nov 24, 2003, in forum: Ruby
    Replies:
    0
    Views:
    85
    Masao Mutoh
    Nov 24, 2003
Loading...

Share This Page