ashbb / green_shoes

Green Shoes is one of the colorful Shoes written in pure Ruby.
Other
204 stars 37 forks source link

Speed of chipmunk decrease #46

Closed glurp closed 13 years ago

glurp commented 13 years ago

In this maquette https://gist.github.com/1165270

When lines 74/75 are activate, the programe can't work a long time.

In top of file, I do some patch on chipmunk, which are ok for long-time running. but when i append a dynamiques 'rect' and 'rect.remove', the application dead quicly.

Furthermore, I append _app_delete_mouseevent() to Basic.remove :

class Shoes class Basic def remove @app.delete_mouse_events self @app.canvas.remove @real unless @hided @hided = true if self.is_a?(ShapeBase) end end end

I don't kow if it is ok

by

ashbb commented 13 years ago

Hi raubarede,

1st: Within the line 72-76, you've been creating a new rect element each ten times in a second. Even if you remove them, their memory areas are not freed soon. I know this is a problem. But I have not yet found a solution. :(

So, I recommend you to use show/hide instead of create/remove.

2nd: About appending app_delete_mouse_event() to Basic#remove. Looks good. But the Basic#remove method is one of the fundamental methods in Green Shoes, so need to do enough tests.

By the way, when is this patch necessary? What problem does this patch solve?

Could you show me a little snippet to recreate the problem?

ashbb

glurp commented 13 years ago

Hello ahbb,

My apologise, the code break with delete_mouse_events() Here is the code :

require 'green_shoes'
if ARGV.size>0
    class Shoes
      class Basic
        def remove
          app.delete_mouse_events self
          app.canvas.remove real unless hided
          hided = true if self.is_a?(ShapeBase)
        end
      end
    end
end

Shoes.app width:200,height:200 do
    i=0
    h={}
    n=50
    color=rgb(n,n,n)
    animate(100) do
        h[i].remove if h[i]
        row=i%10 ; col=i/10
        h[i]=oval row*20,col*20,9,{index: i, fill: color}
        h[i].click {  alert( "Hello Teacher:)") }
        i = (i+1)%100
        (n=((n+40)%255);color=rgb(255-n,n,n)) if i==0
    end
end

for the chipmunk maquette, I try to only change colour, it's seem to work. I am not sure that gs+chipnunk will keep on for a long time running... perhaps i must abandon chipmunk.

by, and thank you for the responses

2011/8/24 ashbb < reply@reply.github.com>

Hi raubarede,

1st: Within the line 72-76, you've been creating a new rect element each ten times in a second. Even if you remove them, their memory areas are not freed soon. I know this is a problem. But I have not yet found a solution. :(

So, I recommend you to use show/hide instead of create/remove.

2nd: About appending app_delete_mouse_event() to Basic#remove. Looks good. But the Basic#remove method is one of the fundamental methods in Green Shoes, so need to do enough tests.

By the way, when is this patch necessary? What problem does this patch solve?

Could you show me a little snippet to recreate the problem?

ashbb

Reply to this email directly or view it on GitHub: https://github.com/ashbb/green_shoes/issues/46#issuecomment-1888775


_ . _ |) | / ` | /` | \ |_ > L| .__/

http://regisaubarede.posterous.com/


glurp commented 13 years ago

My chipmunk demo is running, I think I understand what's appen : when the number of shape to draw is too high for animate() cadence, then nothing is displayed, we think that application is broken. by limiting the number of shape displayed do ~ max 300 (chipmunk driven+static) the display stay smooth.

2011/8/24 ashbb < reply@reply.github.com>

Hi raubarede,

1st: Within the line 72-76, you've been creating a new rect element each ten times in a second. Even if you remove them, their memory areas are not freed soon. I know this is a problem. But I have not yet found a solution. :(

So, I recommend you to use show/hide instead of create/remove.

2nd: About appending app_delete_mouse_event() to Basic#remove. Looks good. But the Basic#remove method is one of the fundamental methods in Green Shoes, so need to do enough tests.

By the way, when is this patch necessary? What problem does this patch solve?

Could you show me a little snippet to recreate the problem?

ashbb

Reply to this email directly or view it on GitHub: https://github.com/ashbb/green_shoes/issues/46#issuecomment-1888775


_ . _ |) | / ` | /` | \ |_ > L| .__/

http://regisaubarede.posterous.com/


ashbb commented 13 years ago

Hi Regis,

Thank you for posting your findings. Finally, is there no more questions related to this topic? If so, please close this issue (#46). And if you will find other issues, feel free to open new tickets.

If there are unsolved issues I overlooked, please point out again. ;-)

Thanks, ashbb