What does it mean to lock or unlock a JsVar? #7627
Replies: 1 comment
-
Posted at 2020-11-27 by @gfwilliams Hi! That sounds spot on. The reasoning behind the lock counter is that sometimes (GC, as you mentioned, or when compacting variables) the interpreter needs to know when a variable is 'in use' and so cannot be moved around or freed. The vars have a 'lock counter' which you can read either using the If you have a pointer to the variable in your C code, the variable should be locked. If you compile without Hope that helps! Posted at 2020-11-27 by Gary.Ott Hi Gordon, thank you for taking the time to provide a very helpful answer. I feel more confident about what I'm doing now. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-11-26 by Gary.Ott
I'm learning to create my own extensions for Espruino. I have read the various guides and documentation and referred to existing libraries which have enabled me to succeed in making a simple extension that does not leak memory.
My success is despite uncertainty around the purpose of
jsUnLock()
and when to use it. My understanding so far is:jsvNew[Whatever]()
functions return locked variables.unlocked.
Have I misunderstood anything? Is there anything significant I am missing?
Beta Was this translation helpful? Give feedback.
All reactions