tags:

views:

120

answers:

2

Got these functions which are just part of simple slideshow. After some 100 repeats it throws an Stack overflow (IE6) or out of memory (IE 7-8)...

Don't see anything wrong here really...Any ideas?

function show($itemNumber) {
                $("#mainImage").stop();
                $("#mainImage").fadeOut(fadingSpeed, function() {
                    $("#mainImage").unbind('load');
                    $("#mainImage").load(function() {
                        $("#mainImage").fadeIn(fadingSpeed);
                    });
                    $("#mainImage").attr('src',items[$itemNumber].img);
                    $("#mainText").html(items[$itemNumber].text);

                    currentItem = $itemNumber;
                });
                return false;
            }

            function moveOneSlide() {
                if (slideshow === true) {
                    currentItem++;
                    if (currentItem >= items.length) {
                        currentItem = 0;
                    }
                    setTimeout(moveOneSlide, interval);
                    show(currentItem);
                }
            }
A: 

I checked this but upto 1115 images, i did't get any errors this is the code i checked.

      <script type="text/javascript" src="js/jquery.js"></script>
   <script type="text/javascript">
   var items = [{'img':'smiles/1.gif','text':'hello'},
    {'img':'smiles/2.gif','text':'hi'},
    {'img':'smiles/3.gif','text':'hello'},
    {'img':'smiles/4.gif','text':'hi'},
    {'img':'smiles/5.gif','text':'hello'},
    {'img':'smiles/6.gif','text':'hi'},
    {'img':'smiles/7.gif','text':'hello'},
    {'img':'smiles/8.gif','text':'hi'},
    {'img':'smiles/9.gif','text':'hello'},
    {'img':'smiles/10.gif','text':'hi'},
    {'img':'smiles/11.gif','text':'hello'},
    {'img':'smiles/12.gif','text':'hi'},
    {'img':'smiles/13.gif','text':'hello'},
    {'img':'smiles/14.gif','text':'hi'},
    {'img':'smiles/15.gif','text':'hello'},
    {'img':'smiles/16.gif','text':'hi'},
    {'img':'smiles/17.gif','text':'hello'},
    {'img':'smiles/18.gif','text':'hi'},
    {'img':'smiles/19.gif','text':'hello'},
    {'img':'smiles/20.gif','text':'hi'},
    {'img':'smiles/21.gif','text':'hello'},
    {'img':'smiles/22.gif','text':'hi'},
    {'img':'smiles/23.gif','text':'hello'},
    {'img':'smiles/24.gif','text':'hi'},
    {'img':'smiles/25.gif','text':'hello'},
    {'img':'smiles/26.gif','text':'hi'},
    {'img':'smiles/27.gif','text':'hello'},
    {'img':'smiles/28.gif','text':'hi'},
    {'img':'smiles/29.gif','text':'hello'},
    {'img':'smiles/30.gif','text':'hi'},
    {'img':'smiles/31.gif','text':'hello'},                                
    {'img':'smiles/32.gif','text':'hi'},
    {'img':'smiles/33.gif','text':'hello'},
    {'img':'smiles/34.gif','text':'hi'},
    {'img':'smiles/35.gif','text':'hello'},
    {'img':'smiles/36.gif','text':'hi'},
    {'img':'smiles/37.gif','text':'hello'},
    {'img':'smiles/38.gif','text':'hi'},
    {'img':'smiles/39.gif','text':'hello'},
    {'img':'smiles/41.gif','text':'hi'},
    {'img':'smiles/42.gif','text':'hello'},
    {'img':'smiles/43.gif','text':'hi'},
    {'img':'smiles/44.gif','text':'hello'},
    {'img':'smiles/45.gif','text':'hi'},
    {'img':'smiles/46.gif','text':'hello'},
    {'img':'smiles/47.gif','text':'hi'},
    {'img':'smiles/48.gif','text':'hello'},
    {'img':'smiles/49.gif','text':'hi'},
    {'img':'smiles/50.gif','text':'hello'},
    {'img':'smiles/51.gif','text':'hi'},
    {'img':'smiles/52.gif','text':'hello'},
    {'img':'smiles/53.gif','text':'hi'},
    {'img':'smiles/54.gif','text':'hello'},
    {'img':'smiles/55.gif','text':'hi'},
    {'img':'smiles/56.gif','text':'hello'},
    {'img':'smiles/57.gif','text':'hi'},
    {'img':'smiles/58.gif','text':'hello'},
    {'img':'smiles/59.gif','text':'hi'},
    {'img':'smiles/60.gif','text':'hello'},
    {'img':'smiles/61.gif','text':'hi'},
    {'img':'smiles/62.gif','text':'hello'},
    {'img':'smiles/63.gif','text':'hi'},
    {'img':'smiles/64.gif','text':'hello'},
    {'img':'smiles/65.gif','text':'hi'},
    {'img':'smiles/66.gif','text':'hello'},
    {'img':'smiles/67.gif','text':'hi'},
    {'img':'smiles/68.gif','text':'hello'},
    {'img':'smiles/79.gif','text':'hi'},
    {'img':'smiles/70.gif','text':'hello'},
    {'img':'smiles/71.gif','text':'hi'},
    {'img':'smiles/72.gif','text':'hello'},
    {'img':'smiles/73.gif','text':'hi'},
    {'img':'smiles/74.gif','text':'hello'},
    {'img':'smiles/75.gif','text':'hi'},
    {'img':'smiles/76.gif','text':'hello'},
    {'img':'smiles/77.gif','text':'hi'}];

next

    fadingSpeed=10;
    interval=1000;
    currentItem=0;
    count='0'
   function show($itemNumber) {
    count++;
    //$("#mainImage").stop();
    $("#mainImage").fadeOut(fadingSpeed, function() {
     $("#mainImage").unbind('load');
     $("#mainImage").load(function() {
      $("#mainImage").fadeIn(fadingSpeed);
     });
     $("#mainImage").attr('src',items[$itemNumber].img);
     $("#mainText").html(items[$itemNumber].text);
     $("#mainNum").html(count)
     currentItem = $itemNumber;
    });
    return false;
   }

   function moveOneSlide() {
     currentItem++;
     if (currentItem >= items.length) {
      currentItem = 0;
     }
     setTimeout(moveOneSlide, interval);
     show(currentItem);
     }

   $(document).ready(function(){
    moveOneSlide();
   });
   </script>

html

<body>
<div id="container">
<img src="" id='mainImage'>
<div id='mainText'></div> 
<div id='mainNum'></div> 
</div>
</body>
</html>
Srikanth
don't see how this is related...
Martin
can u tell me how many images are there in your items.
Srikanth
A: 

You're creating several functions every call here. Consider moving them out of the loop and set them via the named variable to lower memory usage. Additionally, are you showing us your whole function? There's no recursion going on there; it seems like you're setting it up with the moveOneSlide() function, but in your code it's not being called. Make sure you posted all of the relevant code.

Cide