Manual Garbage Collection

Discussion in 'Ruby' started by Conan, Jun 13, 2007.

  1. Conan

    Conan Guest

    Hi. I'm having a problem with a Ruby-Gnome2 application I've been
    building. For some reason(which I haven't identified but I suspect is
    ruby-gnome problem) my program randomly segfaults. I fixed this by
    disabling garbage collection(Maybe GC was cleaning up objects that were
    still in use?) but of course now my application runs out of memory
    relatively quickly. I know which parts of my non-gnome related code are
    memory hogs, and I was wondering if there is a way to manually garbage
    collect specific objects(and their dependencies hopefully)? Or,
    alternatively, is their a way to only run garbage collection within a
    certain scope?

    I'd love a solution to this, as my current alternatives are either
    running out of memory or random segfaults.

    --
    Posted via http://www.ruby-forum.com/.
    Conan, Jun 13, 2007
    #1
    1. Advertising

  2. On 6/13/07, Conan <> wrote:
    > Hi. I'm having a problem with a Ruby-Gnome2 application I've been
    > building. For some reason(which I haven't identified but I suspect is
    > ruby-gnome problem) my program randomly segfaults. I fixed this by
    > disabling garbage collection(Maybe GC was cleaning up objects that were
    > still in use?)


    Not very likely, the GC if anything tends not to free objects which
    are still referenced rather than the other way around. Segfaults are
    almost always caused by flawed extension code in C/C++ I think that
    ruby-gnome2 might have a bit of that. <G>.

    I've not used or looked at Ruby-Gnome2 but I'd look to see if it was
    using finalizers. It could be that the bug is being exposed by their
    code which runs in a finalizer. Turning off GC would prevent this
    code from running.

    > but of course now my application runs out of memory
    > relatively quickly. I know which parts of my non-gnome related code are
    > memory hogs, and I was wondering if there is a way to manually garbage
    > collect specific objects(and their dependencies hopefully)? Or,
    > alternatively, is their a way to only run garbage collection within a
    > certain scope?


    I'm afraid not.

    > I'd love a solution to this, as my current alternatives are either
    > running out of memory or random segfaults.


    Or tracking down what's actually segfaulting. Perhaps there are some
    ideas in this thread:
    http://www.ruby-forum.com/topic/110106

    --
    Rick DeNatale

    My blog on Ruby
    http://talklikeaduck.denhaven2.com/
    Rick DeNatale, Jun 13, 2007
    #2
    1. Advertising

  3. Ok, I'll see if I can find(and hey, maybe disable) ruby-gnome's
    finalizers that may be causing problems. Thanks for your help, at least
    now I've got an idea of where to look.

    --
    Posted via http://www.ruby-forum.com/.
    Conan Rubymanjaro, Jun 13, 2007
    #3
  4. Conan Rubymanjaro wrote:
    > Ok, I'll see if I can find(and hey, maybe disable) ruby-gnome's
    > finalizers that may be causing problems. Thanks for your help, at least
    > now I've got an idea of where to look.


    If anyone is interested in knowing more, I've continued this thread in
    http://www.ruby-forum.com/topic/111736 with code examples.

    --
    Posted via http://www.ruby-forum.com/.
    Conan Rubymanjaro, Jun 13, 2007
    #4
    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. Replies:
    1
    Views:
    440
    mrstephengross
    Jul 25, 2005
  2. Øyvind Isaksen
    Replies:
    1
    Views:
    965
    Øyvind Isaksen
    May 18, 2007
  3. Replies:
    14
    Views:
    608
    Bo Persson
    Jun 18, 2008
  4. dkmd_nielsen
    Replies:
    5
    Views:
    134
    Gary Wright
    Mar 13, 2007
  5. Tridib Bandopadhyay
    Replies:
    25
    Views:
    485
    Tridib Bandopadhyay
    May 20, 2011
Loading...

Share This Page