-
-
Notifications
You must be signed in to change notification settings - Fork 136
Feature: Provide a JS helper function on the global object to release the native object wrapped by a JS instance #1254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Analogous to this feature in the iOS runtime: NativeScript/ios-jsc#1062 |
mbektchiev
added a commit
to NativeScript/NativeScript
that referenced
this issue
Feb 7, 2019
* Add `releaseNativeObject` function in `utils` * Add tests * Add typings for the global `__releaseNativeCounterpart` functions provided by Android and iOS runtimes refs NativeScript/ios-jsc#1062 and NativeScript/android#1254
Merged
5 tasks
mbektchiev
added a commit
to NativeScript/NativeScript
that referenced
this issue
Feb 7, 2019
* Add `releaseNativeObject` function in `utils` * Add tests * Add typings for the global `__releaseNativeCounterpart` functions provided by Android and iOS runtimes refs NativeScript/ios-jsc#1062 and NativeScript/android#1254
mbektchiev
added a commit
to NativeScript/NativeScript
that referenced
this issue
Feb 7, 2019
* Add `releaseNativeObject` function in `utils` * Add tests * Add typings for the global `__releaseNativeCounterpart` functions provided by Android and iOS runtimes refs NativeScript/ios-jsc#1062 and NativeScript/android#1254
mbektchiev
added a commit
to NativeScript/NativeScript
that referenced
this issue
Feb 8, 2019
* Add `releaseNativeObject` function in `utils` * Add tests * Add typings for the global `__releaseNativeCounterpart` functions provided by Android and iOS runtimes refs NativeScript/ios-jsc#1062 and NativeScript/android#1254
SvetoslavTsenov
pushed a commit
to NativeScript/NativeScript
that referenced
this issue
Feb 8, 2019
…6873) * Add `releaseNativeObject` function in `utils` * Add tests * Add typings for the global `__releaseNativeCounterpart` functions provided by Android and iOS runtimes refs NativeScript/ios-jsc#1062 and NativeScript/android#1254
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
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.
The text was updated successfully, but these errors were encountered: