cycle
cycle copied to clipboard
Plugin freezes after 2-3 hours of showing the same effect.
Hi, I've been using your plugin a lot lately showing off a page cycling images for an extend period of time and it looks like after a couple of hours it freezes.
My hypothesis is that the circular reference inside the "go" main engine function leaks memory and at some point the Javascript Interpreter stops it. I'm not sure about it but I think I'm pretty close.
My solution to the issue is to trigger an event called "cycle.jquery" and catch it somewhere else and then set the timeout to call the "go" function.
Have a look and tell me what you think about it:
@line 60 return this.each(function(){ options = handleArguments(this, options, arg2); [...] // bk patch $(window).bind('cycle.jquery', function(e, p, els, opts, tmp, opts_rev, ms){ p.cycleTimeout= setTimeout(function(){ go(els, opts, tmp, opts_rev) }, ms); }); // if it's an auto slideshow, kick it off if (opts.timeout || opts.continuous) { //this.cycleTimeout = setTimeout(function(){go(els,opts,0,!opts.rev)}, opts.continuous ? 10 : opts.timeout + (opts.delay||0)); $(window).trigger('cycle.jquery', [this, els, opts, 0, !opts.rev, opts.continuous ? 10 : opts.timeout + (opts.delay||0)]); } });
@line 471 function go(els, opts, manual, fwd) { [...] if (ms > 0) { //p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.rev) }, ms); $(window).trigger('cycle.jquery', [p, els, opts, 0, !opts.rev, ms]); } }
I'm pretty sure this can be done in a cleaner way but so far this solution is the one working for me.
Cheers. David
Hmm, what browser were you seeing this problem in?
Firefox 3.6 and Chrome 5.0
Did you reproduce it? Do you know a better way to solve this?