Is there something like memory friendly scripting in JavaScript? Certain principles I should be aware of? I am asking this because I have a site where a #div gets filled with lots of data and I do this with a primitive .innerHTML = i_hold_lots_of_data; I wonder if a .innerHTML = ''; has the same effect as a free() in C?
So my question could be narrowed down to this: Are there best practises for handling huge strings in JavaScript as concerns memory management?
If you want to get insight into knowing your memory profile, you should use tools like the Google Chrome console (tab Profile). It shows you how much memory is used by which objects.
In general, you should know that javascript variables are references to things in memory, and this memory gets released when there are no references to it anymore (at some point in the near future). So, if you have large objects, make sure you hold on to them for only as long as necessary. If you only need to use something in one place, make sure it has local scope instead of using a global variable.