Memory concerns wrt garbage collection etc

Discussion in 'Ruby' started by Srijayanth Sridhar, May 28, 2008.

  1. Hello,

    I have a script which basically launches several threads, each of them
    parsing a web page from a different link using Hpricot. I am not sure
    how many threads get spawned, could be in the hundreds. The question I
    have is, assuming we have a simple scenario where:

    doc=Hpricot.new(open("http://somewhere/"))
    # a bunch of processing
    doc=Hpricot.new(open("http://somewhere.else/"))
    # some more processing here.


    When does the memory from the first instance get released? As soon as
    no references point to that chunk of memory or right at the end of the
    scope of wherever that object was instantiated?

    Can someone please tell me as I have to my script running for months
    perhaps and I don't know if its going to sit there eating memory for
    no reason :)

    Thank you,

    Jayanth
    Srijayanth Sridhar, May 28, 2008
    #1
    1. Advertising

  2. Srijayanth Sridhar

    Roger Pack Guest


    > doc=Hpricot.new(open("http://somewhere/"))
    > # a bunch of processing
    > doc=Hpricot.new(open("http://somewhere.else/"))
    > # some more processing here.
    >
    >
    > When does the memory from the first instance get released? As soon as
    > no references point to that chunk of memory or right at the end of the
    > scope of wherever that object was instantiated?


    Theoretically as soon as you redefine doc you'll no longer have any
    references to it so it will be collected when the GC "kicks in" or when
    you call GC.start--whichever comes first.
    GL.
    -=R
    --
    Posted via http://www.ruby-forum.com/.
    Roger Pack, Oct 23, 2008
    #2
    1. Advertising

  3. 2008/5/28 Srijayanth Sridhar <>:
    > I have a script which basically launches several threads, each of them
    > parsing a web page from a different link using Hpricot. I am not sure
    > how many threads get spawned, could be in the hundreds.


    I doubt the usefulness of this. Since Ruby uses green threads chances
    are that your overall throughput could be better if you limit the
    number of threads. This also has the effect of reducing the amount of
    memory needed at a point in time. I'd seriously question this design.
    If you have multiple cores in your system and want to take advantage
    of them using multiple processes might also be an option.

    Kind regards

    robert

    --
    remember.guy do |as, often| as.you_can - without end
    Robert Klemme, Oct 24, 2008
    #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. VisionSet

    Good style wrt collection classes

    VisionSet, Sep 27, 2003, in forum: Java
    Replies:
    4
    Views:
    314
    VisionSet
    Sep 29, 2003
  2. memory related concerns

    , Jun 22, 2006, in forum: C Programming
    Replies:
    3
    Views:
    284
  3. Chris Thomasson

    Some quick c++ memory-model concerns...

    Chris Thomasson, Sep 3, 2006, in forum: C++
    Replies:
    0
    Views:
    372
    Chris Thomasson
    Sep 3, 2006
  4. Øyvind Isaksen
    Replies:
    1
    Views:
    948
    Øyvind Isaksen
    May 18, 2007
  5. Kevin Walzer

    Re: PIL (etc etc etc) on OS X

    Kevin Walzer, Aug 1, 2008, in forum: Python
    Replies:
    4
    Views:
    371
    Fredrik Lundh
    Aug 13, 2008
Loading...

Share This Page