Skip to content

I don't get why this goes out of scope #3441

Answered by asmagill
tigersoul925 asked this question in Q&A
Discussion options

You must be logged in to vote

In a seeming paradox, the busier your lua code is (i.e. how much there is to evaluate), the quicker garbage collection occurs. This is why putting it later in your init.lua seems to work -- if you do more in the console or have a very active setup with lots of timers or callbacks, eventually it will be collected.

I discuss local variables and scope in this wiki article I wrote a while back... I need to go through it again to clean it up and add some more examples, before adding it to the official Wiki, but hopefully even in its current state, it will help your understanding: https://github.com/asmagill/hammerspoon/wiki/Variable-Scope-and-Garbage-Collection

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@tigersoul925
Comment options

@Rhys-T
Comment options

@tigersoul925
Comment options

Answer selected by tigersoul925
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants