Update
As per the comments below, this was tested in Chrome and the browser seems to hold on to the memory from the images until the page is no longer actively rendered (reloaded, switched tab, etc.). Unfortunately, this holds true in Firefox and IE as well.
IE and Firefox had much better memory de-allocation (continually dropping memory as the page stayed open) but both still grew indefinitely. Upon switching tabs in both (by opening a new tab) the memory was almost immediately freed.
I haven't inspected your code thoroughly so I'm not sure if this problem can somehow be avoided (it doesn't appear so on first pass) though you should keep in mind that you are continually adding indicies to an ever-growing array that will continue to use more and more memory on its own. Perhaps it is the reference in the array that is sticking around which could be avoided if you came up with another way to implement the slideshow.
The reason why I'm guessing it might be this is from this discussion: garbage collection with node.js. The browser garbage collector needs to ensure that they are not reachable (which they always are, since the array is ever-growing). Thus you have to wait for the garbage collector to clean up the <img>
values inside the indices to free the memory, and that doesn't necessarily happen right when you set them to null.
You'll need to pass your iterator i
to your callback function. Then you'll be able to null the picture after it fades out and free the memory it was using. Just make sure you don't get caught in the common closure-iterator problem -- something like this should work:
pictures[i].fadeIn(500).delay(5000).fadeOut(500, (function(i) {
pictures[i] = null;
})(i);