Does JavaScript's setInterval() method cause memory leak?
stackoverflow.com
stackoverflow.com
You can minimize GC by being clever about re-using objects, avoiding waste. The top answer shows how GC happens less frequently when using a setTimeout loop instead of setInterval, I don't know the underlying reason but that was always recommended before requestAnimationFrame came along.
These days you should use requestAnimationFrame whenever available - it allows the browser to plan ahead for a smoother framerate, adjust rate to the device capabilities, and save resources when it's in the background.
[1] http://phoboslab.org/log/2011/08/are-we-fast-yet [2] https://developers.google.com/v8/design#garb_coll
So you're going to see an increase in memory with each function call until the garbage collector kicks in.
So while the function definition is a literal, the execution most definitely has a cost associated with it.
It's presumably the call stack that the memory is used for.