function map(func, array) {
var size = array.size();
for (var i=0; i < size; i++) {
array= func.invoke(array);
}
}
[/CODE]
Readability-wise, this has been great; however, it looks like it's the source of a pernicious memory-leak, and I can't figure out what exactly is going on.
An example of code that leaks is:
function func(elem) {
return "really long string that will make a memory leak more obvious";
}
var array = [1, 2, 3, 4, 5];
map(method(:func), array);
An example of code that doesn't leak:
for (var i=0; i < array.size(); i++) {
array= func(array);
}
[/CODE]
AFAICT, all we did here was inline the for-loop, nothing else. So, I can't figure out why version-1 with `map` leaks, and version 2 with an inline-for-loop doesn't.
Any insight would be greatly appreciated here!