Cycling a massive pool of images, but not consuming the browser ram

  browser, javascript, memory, performance, ram

I have terabytes of images on disk, and have built a basic javascript routine that pulls one in at random, and displays it as a web browser screensaver. The problem is, if i leave it alone for (say) 24hrs, that browser will use gigs of system RAM.

What is your recommendation for housekeeping that RAM, so that the overhead stays low, and the screensaver can run for days?

let timer = setTimeout(getRandomImage, 100),
    el = $("#pictureframe");

function getRandomImage(){

    let elImageUrl = "https://my.image.url/?v=" + Math.random();
    el.css('background-image', 'url('+ elImageUrl +')');
    setTimeout(getRandomImage, 5000);

Source: Ask Javascript Questions