-
Enhancement
-
Resolution: Won't Fix
-
P4
-
repo-panama
Currently, when (un-)boxing code needs to do an allocation a Scope is created for that, and the scope is then leaked.
For an up-/down-call there are 2 kinds of scopes; 1) for values being passed as arguments by value, which are valid for the duration of the call. 2) for values being returned, which are up to the caller to manage.
We can do better than the current scheme of always leaking, by having UniversalUpcallHandler and UniversalNativeInvoker create both of these types of scopes, pass them to boxing code, and then close scopes of type 1) when the call is finished.
This will reduce the amount of memory being leaked, and could also help identify bugs where references to temporary objects are leaked.
For an up-/down-call there are 2 kinds of scopes; 1) for values being passed as arguments by value, which are valid for the duration of the call. 2) for values being returned, which are up to the caller to manage.
We can do better than the current scheme of always leaking, by having UniversalUpcallHandler and UniversalNativeInvoker create both of these types of scopes, pass them to boxing code, and then close scopes of type 1) when the call is finished.
This will reduce the amount of memory being leaked, and could also help identify bugs where references to temporary objects are leaked.