Does executing a Luau function implicitly create a reference to it while it's executing? #1319
Ono-Sendai
started this conversation in
General
Replies: 2 comments
-
|
There is an implicit reference on the thread's call stack which will ensure that function is not collected before it is completed. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
great, thank you. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Consider this Luau code:
In my C++ code I create a reference to onTimerEvent (the first argument to createTimer) in createTimer using lua_ref, to prevent it from being garbage-collected.
Later onTimerEvent is called from C++ code. While it is being executed, it then calls the C++ function destroyTimer, which releases the reference to onTimerEvent with lua_unref.
Is there an implicit reference to onTimerEvent while it is being called (e.g. while on the Lua call stack?)
Or is it in danger of being garbage-collected?
Beta Was this translation helpful? Give feedback.
All reactions