On Oct 29, 7:47 am, Matt Ball <
mattjb...@gmail.com> wrote:
> You're creating a closure, which means that every time you call
> drawTable(), it will use the same values of the outer variables.
> Presumably, table is null at the time that it's bound inside of
> drawTable(), which means that you're going to be new-ing every time.
Err... no.
It will use the /current/ values of those variables each time the
function is called. The first time he calls drawTable, table gets set,
and the if clause never gets called again (unless he explicitly sets
table to null elsewhere in his code).
It still might not be a leak. Theres no way to know when the garbage
collector will run. Uncollected objects will count towards a processes
memory usage, even though they are available to be freed. So the real
question is - can you cause the process to run out of memory by
calling drawTable enough times (you didnt say how much memory was
leaked, so it may not be practical).
Mark