Re:Js Game Wiki
by pachydermic on Tuesday September 10, 2013 @02:22PM
(#6361979)
Yeah I'm still stuck. Not really sure if it's a problem with requestAnimationFrame anymore, though.
If you're so inclined, I'd appreciate if you'd take a look at my stack overflow question.
http://stackoverflow.com/questions/18603962/javascript-memor...
At this point, I'm either fundamentally screwed up in my design or have some small innocuous looking thing which is eating all of my memory.
I initially posted this, but now I'm not sure if this is what you meant:
Don't do this:
do this: Basically avoid writing anonymous functions for callbacks that are going to be callback-ed more than once.Another thing that might help with memory is make sure you don't keep references to things you want garbage-collected.
E.g. if object `A` has a reference to object `B`, `B`'s memory won't be freed even if you never use it again. MDN has a better explanation and example [1]
As for books I'd recommend Effective Javascript by David Herman.
[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memo...