Memory Management in Single Scene

(steve) #1

Is memory released when I switch DOM elements? I’ve got a single scene interface where I’m swapping out youtube videos, images and html. Quite a bit of it. Will memory be released as I swap assets or is this going to create memory issues? And what if I embed other hype docs in a Rect (iFrame) (one at a time) and swap them - will the memory be released each time the Rect (Embedded Hype Doc) is either changed or cleared all together. A single page interface would work best for what I’m doing but not if it causes memory problems. The hype docs that will be embedded also do quite a bit of swapping and may have some large media assets.


It depends how you’re swapping it. One way to reduce memory pressure is to dynamically insert different iframe src values into a single frame. So you would place a rectangle, give it an ID of ‘scene1box’ and then use this code to dynamically insert the iframe code you wish:

var soundcloud1 = '<iframe src =";auto_play=false&amp;hide_related=false&amp;show_comments=false&amp;show_user=false&amp;show_reposts=false&amp;visual=true&amp;sharing=false" width="100px" height="100px" scrolling="no"></iframe>';

document.getElementById("scene1box").innerHTML = soundcloud1

You could do this with Hype documents, youtube embed codes, or whatever you wish. But I think you should test out the performance of your document with several iframed elements at once and see how it performs – it may be completely fine. If you load 5 youtube embeds, a lot of the code for those will be reused across the videos so it’s not as huge a memory impact as you may think. Loading multiple Hype document within a Hype document might slow things down, depending what you’ve got in there.

Setting elements to ‘Display: Hidden’ in the Element inspector while your elements are off scene will alleviate some graphics memory needs (this will be most noticeable on mobile). But the elements will still be loaded into regular memory if you are on the element’s scene.