- Last post
- 9 Responses
Im building a sideshow that needs to load in and drop dynamic content at regular intervals over an will run over long period of time (12-24 hours).
Does anyone have any examples or reading material to handle this sort of thing?
Excuse my grammar :
... A sideshow that will load in rotate dynamic content then drop it out after a certain time, but be efficient on the memory enough to last for a full day without a reload.
Sooo.... content within the slideshow expires at different intervals, and the script is tight enough as not to bloat and crash.
check client time. load from clientTime/image.jpg.
efficient on the memory...without reload...dynamic content...sounds impossible imo...
maybe a spritesheet with all images in it and then offset by the hour or something...
really depends on the size of the images I guess.
^ a huge sprite sheet is probably going to be more trouble than individual files unless we're talking a clock or something smaller.
I'd suggest something like
var myImage = new Image()
myImage.src = 'url';
// do things with the image, either append to DOM or draw to canvas
//when done with it
that should free up the memory used by the image when the garbage collector comes around.
otherwise, your only problem might be a long running loop, but my link above gives strategies for that.
just obey closure and maybe just change src attribute of a few layers instead of having new elements being swapped in the DOM to keep the memory use low
deleting DOM elements sometimes still doesn't make GC release it from the memory causing a memory leak. The best approach, especially for mobile is to load in 1px image instead of the image you have and then delete. Forcing 1px image to replace the big one will automatically trigger the GC.