Well, there's a leak in the sense that you start an interval timer running that you cannot stop without leaving the page (since you don't keep the handle). That means that the context of the call to act
that created the timer, the timer callback, and A
can never be GC'd, because the browser has a reference to the callback in its timer list, and the callback closes over the context of the call that created it. But I'm assuming that's desired behavior, so not really a leak.
In theory, the a_var
argument is referenced by the closure (indirectly, by referencing the binding object of the execution context of the call to act
), and so sticks around in memory even though you don't use it (you use self.a_var
instead).
In practice (which is to say, allowing for implementation optimizations), it's complicated. Modern engines can optimize out variables and such that they know a closure doesn't access, but surprisingly simple things can disturb that process (at least on V8). This other question and answer have more on that.