Garbage collector

Discussion in 'Ruby' started by Eustáquio Rangel de Oliveira Jr., Jan 8, 2005.

  1. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Hi!

    Hey, how often the garbage collector runs?
    When all the memory becomes full?
    Or there is a pre-defined interval?

    And, do you have some links about the the Ruby mark-and-sweep type of
    garbage?

    Thanks! :)

    - ----------------------------
    Eustáquio "TaQ" Rangel

    http://beam.to/taq
    Usuário GNU/Linux no. 224050
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.6 (GNU/Linux)
    Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

    iD8DBQFB4FmVb6UiZnhJiLsRAoigAJ9A8I2CmLJr9M0vw4FcUagNCsZ2lACdEWyF
    jc4vN0V8OyfZzJIyaN5I6H0=
    =jttK
    -----END PGP SIGNATURE-----
    Eustáquio Rangel de Oliveira Jr., Jan 8, 2005
    #1
    1. Advertising

  2. Eustáquio Rangel de Oliveira Jr.

    Bill Atkins Guest

    It runs when Ruby runs out of memory or when it's manually invoked (by
    ObjectSpace.garbage_collect or GC.start).

    Bill

    On Sun, 9 Jan 2005 07:06:36 +0900, "Eustáquio Rangel de Oliveira Jr."
    <> wrote:
    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >
    > Hi!
    >
    > Hey, how often the garbage collector runs?
    > When all the memory becomes full?
    > Or there is a pre-defined interval?
    >
    > And, do you have some links about the the Ruby mark-and-sweep type of
    > garbage?
    >
    > Thanks! :)
    >
    > - ----------------------------
    > Eustáquio "TaQ" Rangel
    >
    > http://beam.to/taq
    > Usuário GNU/Linux no. 224050
    > -----BEGIN PGP SIGNATURE-----
    > Version: GnuPG v1.2.6 (GNU/Linux)
    > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
    >
    > iD8DBQFB4FmVb6UiZnhJiLsRAoigAJ9A8I2CmLJr9M0vw4FcUagNCsZ2lACdEWyF
    > jc4vN0V8OyfZzJIyaN5I6H0=
    > =jttK
    > -----END PGP SIGNATURE-----
    >
    >



    --
    $stdout.sync = true
    "Just another Ruby hacker.".each_byte do |b|
    ('a'..'z').step do|c|print c+"\b";sleep 0.007 end;print b.chr
    end; print "\n"
    Bill Atkins, Jan 8, 2005
    #2
    1. Advertising

  3. Eustáquio Rangel de Oliveira Jr. wrote:
    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >
    > Hi!
    >
    > Hey, how often the garbage collector runs?
    > When all the memory becomes full?
    > Or there is a pre-defined interval?
    >

    It basically runs when a certain amount of memory is used - see
    malloc_increase and malloc_limit in gc.c. Also, if malloc() fails or
    attempts to open a file fail do to memory limitations the gc will be
    run.


    > And, do you have some links about the the Ruby mark-and-sweep type of
    > garbage?
    >

    http://www.rubygarden.org/ruby?GCAndMemoryManagement
    http://www.rubygarden.org/ruby?GCAndExtensions

    -Charlie
    Charles Mills, Jan 8, 2005
    #3
  4. Eustáquio Rangel de Oliveira Jr. ha scritto:
    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >
    > Hi!
    >
    > Hey, how often the garbage collector runs?
    > When all the memory becomes full?
    > Or there is a pre-defined interval?
    >
    > And, do you have some links about the the Ruby mark-and-sweep type of
    > garbage?
    >
    > Thanks! :)


    btw, I thought 1.9 could see the light of a different GC.. Is someone
    working on that or is it something still very far in the future?
    gabriele renzi, Jan 9, 2005
    #4
  5. "Eustáquio Rangel de Oliveira Jr." <> wrote:
    > And, do you have some links about the the Ruby mark-and-sweep type of
    > garbage?


    While I lack the skill to go source diving, I too am interested in more
    info about the gc.
    We use conservative gc [talk:102873], ok

    So, can one help gc?
    e.g. if an Array or Hash is no longer needed, does an Array.clear or
    Hash.clear actually zero all internal pointers to help/speed up gc?

    How much extra memory does every Ruby object allocation take?
    Any alignment losses?

    Is there e.g. a preallocate for a String - if I know it'll grow to ~10kb
    by using << and I don't want to produce so much temp garbage?


    Martin
    Martin Pirker, Jan 9, 2005
    #5
  6. Martin Pirker wrote:
    > "Eustáquio Rangel de Oliveira Jr." <> wrote:
    >
    >>And, do you have some links about the the Ruby mark-and-sweep type of
    >>garbage?

    >
    >
    > While I lack the skill to go source diving, I too am interested in more
    > info about the gc.
    > We use conservative gc [talk:102873], ok
    >
    > So, can one help gc?
    > e.g. if an Array or Hash is no longer needed, does an Array.clear or
    > Hash.clear actually zero all internal pointers to help/speed up gc?


    Yes, that should help, as the mark function would no more mark all the
    value. But I doubt that would be much of a performance win, because if
    the array-object goes out of scope (it's no more reachable), it's mark
    function would no longer be called. So, you would not want to call
    #clear. But that's just my understanding...

    Regards,

    Michael
    Michael Neumann, Jan 9, 2005
    #6
  7. Hello Michael,

    MN> Martin Pirker wrote:
    >> "Eustáquio Rangel de Oliveira Jr." <> wrote:
    >>
    >>>And, do you have some links about the the Ruby mark-and-sweep type of
    >>>garbage?

    >>
    >>
    >> While I lack the skill to go source diving, I too am interested in more
    >> info about the gc.
    >> We use conservative gc [talk:102873], ok
    >>
    >> So, can one help gc?
    >> e.g. if an Array or Hash is no longer needed, does an Array.clear or
    >> Hash.clear actually zero all internal pointers to help/speed up gc?


    MN> Yes, that should help, as the mark function would no more mark all the
    MN> value. But I doubt that would be much of a performance win, because if
    MN> the array-object goes out of scope (it's no more reachable), it's mark
    MN> function would no longer be called. So, you would not want to call
    MN> #clear. But that's just my understanding...

    This would only help if there is something on the stack that looks
    like an address to this array object. The chance for this is very low
    and so the performance win. With the Boehm-Weisser GC i a measurable
    memory reduction (~20%) by doing this for eiffel. But Boehm-Weisser
    scans everything conservative and not only the heap like ruby.

    --
    Best regards, emailto: scholz at scriptolutions dot com
    Lothar Scholz http://www.ruby-ide.com
    CTO Scriptolutions Ruby, PHP, Python IDE 's
    Lothar Scholz, Jan 9, 2005
    #7
  8. Lothar Scholz wrote:
    > Hello Michael,
    >
    > MN> Martin Pirker wrote:
    >
    >>>"Eustáquio Rangel de Oliveira Jr." <> wrote:
    >>>
    >>>
    >>>>And, do you have some links about the the Ruby mark-and-sweep type of
    >>>>garbage?
    >>>
    >>>
    >>>While I lack the skill to go source diving, I too am interested in more
    >>>info about the gc.
    >>>We use conservative gc [talk:102873], ok
    >>>
    >>>So, can one help gc?
    >>>e.g. if an Array or Hash is no longer needed, does an Array.clear or
    >>>Hash.clear actually zero all internal pointers to help/speed up gc?

    >
    >
    > MN> Yes, that should help, as the mark function would no more mark all the
    > MN> value. But I doubt that would be much of a performance win, because if
    > MN> the array-object goes out of scope (it's no more reachable), it's mark
    > MN> function would no longer be called. So, you would not want to call
    > MN> #clear. But that's just my understanding...
    >
    > This would only help if there is something on the stack that looks
    > like an address to this array object. The chance for this is very low
    > and so the performance win. With the Boehm-Weisser GC i a measurable
    > memory reduction (~20%) by doing this for eiffel. But Boehm-Weisser
    > scans everything conservative and not only the heap like ruby.


    Hm, my understanding of Ruby's GC is that it scans the stack
    conservative (meaning that all values on the stack that look like
    references to memory are handled as references), but not the heap (how
    could you conservativly scan the heap?). But probably I misunderstood you.

    And my final conclusion was that it does not help much, if any, despite
    my initial "Yes" ;-)

    Regards,

    Michael
    Michael Neumann, Jan 9, 2005
    #8
  9. Hello Michael,

    >> memory reduction (~20%) by doing this for eiffel. But Boehm-Weisser
    >> scans everything conservative and not only the heap like ruby.


    MN> Hm, my understanding of Ruby's GC is that it scans the stack
    MN> conservative (meaning that all values on the stack that look like
    MN> references to memory are handled as references), but not the heap (how
    MN> could you conservativly scan the heap?). But probably I misunderstood you.

    Yes. It was a typo i meant "not only the stack like ruby".
    Sorry for the confusion.


    --
    Best regards, emailto: scholz at scriptolutions dot com
    Lothar Scholz http://www.ruby-ide.com
    CTO Scriptolutions Ruby, PHP, Python IDE 's
    Lothar Scholz, Jan 9, 2005
    #9
    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. Rob Tillie

    Garbage Collector Debugging

    Rob Tillie, Aug 15, 2003, in forum: ASP .Net
    Replies:
    11
    Views:
    1,755
    JerryK
    Aug 18, 2003
  2. Pyramis
    Replies:
    0
    Views:
    395
    Pyramis
    Jan 25, 2004
  3. Colt

    Garbage collector problem

    Colt, Nov 15, 2003, in forum: Java
    Replies:
    9
    Views:
    680
    Tim Ward
    Nov 18, 2003
  4. bart59
    Replies:
    0
    Views:
    495
    bart59
    Jun 17, 2004
  5. Will Hartung

    Garbage Collector Tuning?

    Will Hartung, Sep 8, 2004, in forum: Java
    Replies:
    3
    Views:
    2,091
    Kevin McMurtrie
    Sep 11, 2004
Loading...

Share This Page