Thanks :)
I modified my code and it seems much better...

I will run it tonight and see the result tomorrow ;)
If it's better I will post the enhanced code.

cheers
--
Benjamin

On Tue, Apr 15, 2008 at 4:08 PM, _why <[EMAIL PROTECTED]> wrote:
> On Tue, Apr 15, 2008 at 10:50:14AM +0200, ruby francisoud wrote:
> > I made a tiny "time bomb" app with Shoes.
> > But after runnning it for a few hours, the shoes process is eating and
> > consuming lots of memory until it crash and vanish :(
>
> It's true.  You will want to split your app up into classes or
> methods.  Ruby does not garbage collect if everything stays in the
> top scope.
>
> Something like:
>
>  class TimeBomb < Shoes
>    url "/", :setup
>
>    def setup
>      stack :margin => 10 do
>        counter = Counter.new(Time.parse("05/30/2008 17:30"))
>        animate(100) do
>          redraw
>        end
>      end
>    end
>
>    def redraw
>      clear do
>        background black
>        stack do
>          style = {:align => "center", :stroke => white}
>          counter.update
>          para "Tic Tac...", style
>          label = strong(counter.left) if(counter.time_left > 0)
>          label = strong("Boom!") if(counter.time_left <= 0)
>          para label, style
>        end
>      end
>    end
>  end
>
>  Shoes.app :height => 100, :width => 350
>
> Even better would be to just use `replace` on the labels rather than
> clearing the whole slot.  Samples like samples/simple-anim-text.rb
> and samples/simple-timer.rb illustrate how.
>
> _why
>



-- 
Benjamin Francisoud
http://rubyscube.blogspot.com

Reply via email to