We no longer leak memory as the state machine's model is stored by a weak reference.
When the actor goes out of scope, the model is removed by the weakref's finalizer.
This took some doing and I'm hoping transitions could support this usecase more easily in the future.
As a side effect, state machine inheritance is now faster as none of the models are deepcopied into the newly created state machine.
This should have been the case in the first place, however with this patch it is crucial since attempting to deepcopy an empty weakref
results in a ReferenceError.
Something went wrong despite trying multiple times, sorry about that.
Please comment this pull request with "Retry DeepCode" to manually retry, or contact us so that a human can look into the issue.
We no longer leak memory as the state machine's model is stored by a weak reference. When the actor goes out of scope, the model is removed by the weakref's finalizer. This took some doing and I'm hoping transitions could support this usecase more easily in the future.
As a side effect, state machine inheritance is now faster as none of the models are deepcopied into the newly created state machine. This should have been the case in the first place, however with this patch it is crucial since attempting to deepcopy an empty weakref results in a
ReferenceError
.