|
|
|
|
|
by cheapsteak
4667 days ago
|
|
Could you elaborate on the problem you're having with callbacks and requestAnimationFrame? I initially posted this, but now I'm not sure if this is what you meant: Don't do this: requestAnimationFrame(function () {
//a new instance of this function is created every time
})
do this: var efficientFunc = function () {
//this is created only once and is reused
requestAnimationFrame(efficientFunc);
}
requestAnimationFrame(efficientFunc);
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... |
|
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.