anyway, it just looks stupid that the garbage collector have that zigzag pattern at all
what memory does it allocate ? it uses one global variable and that's all
I didn't even declare a new variable.
This is strange indeed
1. garbage source.
Case in point of a possible source: calling a function needs a local scope/closure to be created and destroyed (technically - a good jit optimizer under specific conditions can prevent it from using generic GC for cleanup).
2. zigzag pattern.
Garbage collection is an overhead (ie. in a sense no useful work is done - GC is hardly the goal of any program
). Hence GC implementations avoid actually doing it if they do not need to do it (ie. there is plenty of free memory) - allowing memory usage to steadily grow till it finally decides to do the work causing a sudden drop in memory usage => zigzag.
it seems to leak according to chrome dev tools
I have not used chrome dev tools, but i guess you are misinterpreting what it tells you.
I don't think this is a case of circular dependencies or anything to do with DOM
Yep. However, memory is not free till GC tells so => every unused crumb of memory piles up over time till GC gets rid of them all, all at once.
One might have a leak problem if memory usage grows over GC cycles (ie zigzag bottom line keeps growing).
Edited by tanzanite7, 26 March 2014 - 03:40 AM.