C++ implementation leaks memory whenever a function reference is returned
Opened this issue · 2 comments
rocketorbit commented
code to trigger it:
a = function
b = function
end function
end function
while true
a
end while
JoeStrout commented
It appears that returning a function defined locally automatically causes a reference loop — perhaps because of the outer context binding. The context includes a reference to the function, which includes a reference to the context.
JoeStrout commented
I'm not sure at the moment if there is a simple fix for this, short of switching over to some sort of mark-and-sweep GC system.
For the upcoming minor release, let's look for a simple/easy/safe solution for this particular case. If we can find one, great. If not, we'll punt on this for now (and start planning for a more sophisticated GC).