From: Eero Saynatkari Date: 2006-01-23T00:34:41+09:00 Subject: Re: Minimizing memory allocations Ilmari Heikkinen wrote: > So there I was this morning, staring at an ObjectSpace counter telling > me that I'm allocating 1500 Arrays and 10000 Floats per frame. Which > pretty much ground my framerate to ground by requiring a 0.2s GC run > every other frame. So I decided to get down and rid my code of as many > allocations as possible. > > < snip due to ruby-forum restrictions /> > > In order to turn a Fixnum into a double, it's allocating a new Float! > With that figured out, I took and rewrote rb_num2dbl as rb_num_to_dbl, > this time handling Fixnums and Bignums as special cases as well: > > < snip /> > > The result? Float allocations fell to 700 per frame from the original > 3000. And now I'm getting a GC run "only" every 36 frames. Not perfect > by any means, but a decent start. Nice! I wonder if this would be eligible for core patching? > Have stories of your own? Tips for memory management? Ways to track > allocations? Post them, please. Nope, but I enjoyed reading this one, thanks! > Cheers, > Ilmari E -- Posted via http://www.ruby-forum.com/.