Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Usually the way you solve GC issues is by either not allocating after some initial massive allocation, or by running the GC constantly and having it clean up bits and peices every frame. I don't know enough about ruby to know if this is possible but this is how you handle GC in Java and C#.

As for Lua, Garry's mod runs almost entirely in Lua (outside of the source engine).



You can run GC manually in Ruby, but at the end of the day, it's a stop-the-world GC; your program doesn't get to do anything until it decides that it's finished. If that takes too long, you drop that frame. Additionally, Ruby doesn't have the concept of primitives (mostly), and all objects are stored on the heap! So, every time you use a float (which you do a lot of in games), you end up with a new struct on the heap that has to be garbage collected eventually. Ouch.

(By way of demonstration:)

    ree-1.8.7-2011.03 :002 > 123.456.object_id
     => 33681660
    ree-1.8.7-2011.03 :003 > 123.456.object_id
     => 33674740
Languages with incremental GCs will yield between phases of the GC pass, letting program execution continue even when a GC pass is in progress, making sure that you don't end up with dropped frames, which vastly improves the player experience.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: