views:

50

answers:

2

hi guys,

i have this code that was made from tips here long time ago.

var tm
var tn;
var rot = true;
var rot2 = true;
var th = 482;
var tmh = 0;
var $paneTarget = $('#lyr1');

var slideshow = {
    delay: 5000,
    actions:[],
    run: function() {
        if (slideshow.actions.length) {
            var current = slideshow.actions.shift(); 
            current(); 
            slideshow.actions.push( current ); 
            tm = setTimeout(slideshow.run, slideshow.delay); 
        }
    },
    play: function(n) {
        if (n!=true)
            $(document).clearQueue();
        if (slideshow.actions.length) {
            tm = setTimeout(slideshow.run, slideshow.delay); 
        }
    },
    pause: function() {
        clearTimeout(tm);
        $(document).clearQueue();
    }
};

$(".sideimg").each(function(){
    var that = this;
    slideshow.actions.push(function(){
        if (tn != "") {
            out(tn);
        **}**
        over($(that).attr("id"));
        n = $(that).attr("id").substring($(that).attr("id").indexOf("img")+3,$(that).attr("id").length)
        info("image.asp?id="+n+"","info");
        var $target = $paneTarget.find('#'+$(that).attr("id"));
        var timg = document.getElementById($(that).attr("id"));
        if (timg.offsetTop>th||timg.offsetTop+timg.height>th||timg.offsetTop<tmh) {
            $paneTarget.stop().scrollTo( $target , 800 );

            tmh = timg.offsetTop;
        }
        $("#rimg").fadeOut("slow",function () {
            slideshow.pause;
            $("#rimg").attr("src",$(that).attr("bsrc")).load(function(){
                $("#rimg").attr("alt",$(that).attr("alt"));
                $("#rimg").fadeIn("normal");
                slideshow.play;
            });

        });
        tn = $(that).attr("id");
    });
});

the error is: "out of memory at line: 37" that line is the bold } (bold is not working because it is inside a code line so look for **}**)

it is not coming up after first loop or even the second - it takes long time until it will show up... maybe 20 min?

i had it runing in IE got the message... had it in Chrome and seems to be ok... had it in FF with firebug to see the DOM but no error after an hour

i realy don't know what to do...

update - i'm using jquery 1.4.1 and the error is in the jquery library (after 22-23 minutes of loop trought the images) i still don't know what to do

A: 

Ideally, all the objects your code allocates should be properly deallocated by the JS garbage collector. However, there are differences between the garbage collection implementation on the different browsers, which would explain why you see this error in IE only.

In particular, I know of at least one bug in earlier versions of IE (6 and below, don't know if it's there in 7+) where objects with circular references are not properly collected, thus leaking memory. I suspect you are hitting either this particular bug, or something similar.

Unfortunately, I don't have an easy solution for you; you might have to look into restructuring your code a bit to avoid the memory leaks.

Franci Penov
do you have any suggestions for restructuring my code?
Y.G.J
No, unfortunately I can't help you there. Sorry, JS is not my forte...
Franci Penov
A: 

The problems I see:

slideshow.pause;
slideshow.play;

Should be

slideshow.pause();
slideshow.play();

n is not defined: whatever you want with it define it in the correct scope.

Finally I don't know what over() and out(); is

galambalazs