-
-
Notifications
You must be signed in to change notification settings - Fork 141
Description
Is your feature request related to a problem? Please describe.
When a native object is created from JS code, it’s kept alive by a strong reference in the runtime until the JavaScript object is garbage collected. This can create a memory problem in cases where large objects are instantiated and the JS VM doesn’t collect them after they are practically dead due to low memory pressure in its heap.
Describe the solution you'd like
A new helper function with a signature looking like: __releaseNativeCounterpart(objectToBeReleased)
, would help in earlier releasing of the strong connection when the user decides the (possibly heavy) native object will no longer be used in JS. This would then enable the Android runtime to garbage collect the object earlier — as long as it doesn’t have any other strong references remaining.
Describe alternatives you've considered
Advise users to trigger a JS garbage collection as soon as they are done using heavy objects. This, however, has some performance drawbacks and implications, meaning that it might not be feasible in all cases.