You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use eval_function() to call Starlark functions from Rust, as per the doc.
However, it seems that as long as the module is loaded, the values allocated on the heap passed to eval_function are never freed? The heap keeps growing indefinitely.
I have tried adding verbose_gc() to see if the garbage collector is run, but it shows nothing.
At first I thought it was an issue with my custom type definition, but it seems to behave the same with a standard rust type (ex: heap.alloc("qwe".to_string()).
I tried running it through a different evaluator each time (thinking each evaluator would have its own heap, but that's not the case).
Is there a way to call a function without leaking, except reloading the AST into a new module each time?
Best regards
Unrelated question : what is freeze all about? There are references to it everywhere in the doc, but no explanation about what it entails, when one should use it, ...
Ok, I found a way to work around this by freezing the original module (probably unnecessary?), and creating a temporary module each loop, in which the function from the frozen module is run.
That sounds like it's probably the right solution, it's fairly similar to how buck uses starlark evaluation. I don't think starlark modules are really designed to be long-lived, instead they are designed to be evaluated and then frozen, and the frozen form may be long-lived.
I don't know that there's a fundamental limitation that requires that, just that the use cases have fit well into the evaluate and freeze model. It may be that the interpreter could change to handle well having a long lived active module.
Your solution is probably the right one. The idea is a Module is both the definition and some scratch space for temporary usage. You can garbage collect that with .garbage_collect() on an evaluator, but that requires there are no other Value's floating around.
Hi,
I am trying to use
eval_function()
to call Starlark functions from Rust, as per the doc.However, it seems that as long as the module is loaded, the values allocated on the heap passed to eval_function are never freed? The heap keeps growing indefinitely.
I have tried adding
verbose_gc()
to see if the garbage collector is run, but it shows nothing.At first I thought it was an issue with my custom type definition, but it seems to behave the same with a standard rust type (ex:
heap.alloc("qwe".to_string())
.I tried running it through a different evaluator each time (thinking each evaluator would have its own heap, but that's not the case).
Is there a way to call a function without leaking, except reloading the AST into a new module each time?
Best regards
Unrelated question : what is freeze all about? There are references to it everywhere in the doc, but no explanation about what it entails, when one should use it, ...
The text was updated successfully, but these errors were encountered: