Hi all, I am having a problem where when I call periodically_call_remote the CPU usage goes really high and I have to kill the browser to return the system to normal. I have the following remote call: <%= periodically_call_remote :url => {:action => ''_live_now'' }, :update => ''live_now_list'', :frequency => 10 %> This works fine, at the start. After about 20/30 seconds the CPU starts rising, to 20%, 50%, 70% and higher. At first I have the above remote call in a partial (_live_now.rhtml): <div id="live_now_list"> ... stuff... </div> <%= periodically_call_remote :url => {:action => ''_live_now'' }, :update => ''live_now_list'', :frequency => 10 %> /But/ I did notice that when I moved the periodically_call_remote call to the index.rhtml which contains the partial _live_now.rhtml, the problem does not happen. When I moved it to index.rhtml the CPU stays low and the call works fine every 10 seconds. It''s great that it works but I would like to understand as to why moving the remote call to index.rhtml fixes the problem? Any insights would be greatly appreciated. Cheers, Diego --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
If you are using WEBrick in development mode it is probably checking the partial for updates and reprocessing it, while having it in the rhtml it is only processed once when the page is loaded. Michael On Mar 16, 11:38 pm, "Diego" <d...-MBLnoORfx69BDgjK7y7TUQ@public.gmane.org> wrote:> Hi all, > > I am having a problem where when I call periodically_call_remote the > CPU usage goes really high and I have to kill the browser to return > the system to normal. I have the following remote call: > > <%= periodically_call_remote :url => {:action => ''_live_now'' }, > :update => ''live_now_list'', > :frequency => 10 %> > > This works fine, at the start. After about 20/30 seconds the CPU > starts rising, to 20%, 50%, 70% and higher. > > At first I have the above remote call in a partial (_live_now.rhtml): > > <div id="live_now_list"> > > ... stuff... > > </div> > > <%= periodically_call_remote :url => {:action => ''_live_now'' }, > :update => ''live_now_list'', > :frequency => 10 %> > > /But/ I did notice that when I moved the periodically_call_remote call > to the index.rhtml which contains the partial _live_now.rhtml, the > problem does not happen. When I moved it to index.rhtml the CPU stays > low and the call works fine every 10 seconds. > > It''s great that it works but I would like to understand as to why > moving the remote call to index.rhtml fixes the problem? > > Any insights would be greatly appreciated. > > Cheers, > Diego--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Michael, Thanks for the reply and explaining why this is happening. Even though I''d gotten rid of it, it''s good to know why it was happening. Is there a way that this can be done while running webrick in development mode and not have this happen? Or, if I''m using webrick in development mode, it''s just a matter of putting th remote call outside the partial and just avoiding this problem? Thanks. Diego On Mar 18, 2:32 am, "MichaelLatta" <lat...-ee4meeAH724@public.gmane.org> wrote:> If you are using WEBrick in development mode it is probably checking > the partial for updates and reprocessing it, while having it in the > rhtml it is only processed once when the page is loaded. > > Michael > > On Mar 16, 11:38 pm, "Diego" <d...-MBLnoORfx69BDgjK7y7TUQ@public.gmane.org> wrote: > > > Hi all, > > > I am having a problem where when I call periodically_call_remote the > > CPU usage goes really high and I have to kill the browser to return > > the system to normal. I have the following remote call: > > > <%= periodically_call_remote :url => {:action => ''_live_now'' }, > > :update => ''live_now_list'', > > :frequency => 10 %> > > > This works fine, at the start. After about 20/30 seconds the CPU > > starts rising, to 20%, 50%, 70% and higher. > > > At first I have the above remote call in a partial (_live_now.rhtml): > > > <div id="live_now_list"> > > > ... stuff... > > > </div> > > > <%= periodically_call_remote :url => {:action => ''_live_now'' }, > > :update => ''live_now_list'', > > :frequency => 10 %> > > > /But/ I did notice that when I moved the periodically_call_remote call > > to the index.rhtml which contains the partial _live_now.rhtml, the > > problem does not happen. When I moved it to index.rhtml the CPU stays > > low and the call works fine every 10 seconds. > > > It''s great that it works but I would like to understand as to why > > moving the remote call to index.rhtml fixes the problem? > > > Any insights would be greatly appreciated. > > > Cheers, > > Diego--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
cremes.devlist-ee4meeAH724@public.gmane.org
2007-Mar-18 22:43 UTC
Re: periodically_call_remote eating up lots of CPU.
You can completely avoid the problem by not putting the #periodically_call_remote method in a partial that gets reloaded a lot. As you discovered, each reload creates another instance of the javascript function. Put it in the main page outside the partial. cr On Mar 17, 2007, at 11:43 PM, Diego wrote:> > Hi Michael, > > Thanks for the reply and explaining why this is happening. Even though > I''d gotten rid of it, it''s good to know why it was happening. Is there > a way that this can be done while running webrick in development mode > and not have this happen? Or, if I''m using webrick in development > mode, it''s just a matter of putting th remote call outside the partial > and just avoiding this problem? > > Thanks. > > Diego > > On Mar 18, 2:32 am, "MichaelLatta" <lat...-ee4meeAH724@public.gmane.org> wrote: >> If you are using WEBrick in development mode it is probably checking >> the partial for updates and reprocessing it, while having it in the >> rhtml it is only processed once when the page is loaded. >> >> Michael >> >> On Mar 16, 11:38 pm, "Diego" <d...-MBLnoORfx69BDgjK7y7TUQ@public.gmane.org> wrote: >> >>> Hi all, >> >>> I am having a problem where when I call periodically_call_remote the >>> CPU usage goes really high and I have to kill the browser to return >>> the system to normal. I have the following remote call: >> >>> <%= periodically_call_remote :url => {:action => ''_live_now'' }, >>> :update => ''live_now_list'', >>> :frequency => 10 %> >> >>> This works fine, at the start. After about 20/30 seconds the CPU >>> starts rising, to 20%, 50%, 70% and higher. >> >>> At first I have the above remote call in a partial >>> (_live_now.rhtml): >> >>> <div id="live_now_list"> >> >>> ... stuff... >> >>> </div> >> >>> <%= periodically_call_remote :url => {:action => ''_live_now'' }, >>> :update => ''live_now_list'', >>> :frequency => 10 %> >> >>> /But/ I did notice that when I moved the periodically_call_remote >>> call >>> to the index.rhtml which contains the partial _live_now.rhtml, the >>> problem does not happen. When I moved it to index.rhtml the CPU >>> stays >>> low and the call works fine every 10 seconds. >> >>> It''s great that it works but I would like to understand as to why >>> moving the remote call to index.rhtml fixes the problem? >> >>> Any insights would be greatly appreciated. >> >>> Cheers, >>> Diego > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks CR. Appreciate your input. On Mar 19, 9:43 am, cremes.devl...-ee4meeAH724@public.gmane.org wrote:> You can completely avoid the problem by not putting the > #periodically_call_remote method in a partial that gets reloaded a > lot. As you discovered, each reload creates another instance of the > javascript function. > > Put it in the main page outside the partial. > > cr > > On Mar 17, 2007, at 11:43 PM,Diegowrote: > > > > > Hi Michael, > > > Thanks for the reply and explaining why this is happening. Even though > > I''d gotten rid of it, it''s good to know why it was happening. Is there > > a way that this can be done while running webrick in development mode > > and not have this happen? Or, if I''m using webrick in development > > mode, it''s just a matter of putting th remote call outside the partial > > and just avoiding this problem? > > > Thanks. > > >Diego > > > On Mar 18, 2:32 am, "MichaelLatta" <lat...-ee4meeAH724@public.gmane.org> wrote: > >> If you are using WEBrick in development mode it is probably checking > >> the partial for updates and reprocessing it, while having it in the > >> rhtml it is only processed once when the page is loaded. > > >> Michael > > >> On Mar 16, 11:38 pm, "Diego" <d...-MBLnoORfx69BDgjK7y7TUQ@public.gmane.org> wrote: > > >>> Hi all, > > >>> I am having a problem where when I call periodically_call_remote the > >>> CPU usage goes really high and I have to kill the browser to return > >>> the system to normal. I have the following remote call: > > >>> <%= periodically_call_remote :url => {:action => ''_live_now'' }, > >>> :update => ''live_now_list'', > >>> :frequency => 10 %> > > >>> This works fine, at the start. After about 20/30 seconds the CPU > >>> starts rising, to 20%, 50%, 70% and higher. > > >>> At first I have the above remote call in a partial > >>> (_live_now.rhtml): > > >>> <div id="live_now_list"> > > >>> ... stuff... > > >>> </div> > > >>> <%= periodically_call_remote :url => {:action => ''_live_now'' }, > >>> :update => ''live_now_list'', > >>> :frequency => 10 %> > > >>> /But/ I did notice that when I moved the periodically_call_remote > >>> call > >>> to the index.rhtml which contains the partial _live_now.rhtml, the > >>> problem does not happen. When I moved it to index.rhtml the CPU > >>> stays > >>> low and the call works fine every 10 seconds. > > >>> It''s great that it works but I would like to understand as to why > >>> moving the remote call to index.rhtml fixes the problem? > > >>> Any insights would be greatly appreciated. > > >>> Cheers, > >>>Diego--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---