I've got a web page that's using jquery to receive some product information as people are looking at things and then displays the last product images that were seen. This is in a jquery AJAX callback that looks pretty much like this:
if(number_of_things_seen > 10) {
$('#shots li:last-child').remove();
}
$('<li><img src="' + p.ProductImageSmall + '"></li>').prependTo('#shots');
However, it seems to leak quite a bit of memory. Visually, it does the right thing, but the footprint grows indefinitely.
Safari's DOM inspector shows the DOM is how I would expect it to be, but it seems to maintain references to every image that it has displayed (as seen in this screenshot in case anyone is interested).
I've added
$('#shots li:last-child img').remove();
to the removal statement to no noticable effect.
Is there some magic necessary to let the browser release some of this stuff?