I'm trying to make sure some vars wrapped in a closure will be released for garbage collection when I'm done with them. I'm unsure weather setting them to undefined, or deleting them would be sufficient. Any thoughts?
// run once for each photo, could be hundreds
$("img.photo").each( function(){
// create the vars to put in the callback
var photo = $(this);
var tmp = new Image();
// set the callback, wrapping the vars in its scope
tmp.onload = (function(p,t){
return function(){
// do some stuff
// mark the vars for garbage collection
t.onload = ?
t = ?
p = ?
})(photo, tmp)
// set the source, which calls onload when loaded
tmp.src = photo.attr("src")
})