Skip to content
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

memory leak java <-> javascript when java returns []array #1363

Closed
patricklx opened this issue May 2, 2019 · 6 comments
Closed

memory leak java <-> javascript when java returns []array #1363

patricklx opened this issue May 2, 2019 · 6 comments
Assignees
Milestone

Comments

@patricklx
Copy link

patricklx commented May 2, 2019

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.3.1
  • Cross-platform modules: 5.3.1
  • Android Runtime: 5.3.1
  • iOS Runtime (if applicable):
  • Plugin(s):

Describe the bug

We observe a memory leak when we have the following call thread:
this was to reproduce the ble pattern, but I tested again and I see the leak with only getValue. Looks like it only happens when byte[] is returned. Same issue when String[] is returned.
https://github.com/patricklx/ns-memory-leak/blob/master/app/App_Resources/Android/src/main/java/my/Test.java#L25

I did few memory snapshots, and what is beeing left over is a lot of
system / FunctionTemplateInfo and system / ObjectTemplateInfo

NOTE:
we do not have a memory leak if the getValue does not return the value

markingMode: none, does not help either.

Expected behavior
GC should collect the java array

Sample project
https://github.com/patricklx/ns-memory-leak

this can also be observed with the ble plugin,
since its the same pattern:
https://github.com/EddyVerbruggen/nativescript-bluetooth/blob/master/src/android/TNS_BluetoothGattCallback.ts#L212

@patricklx patricklx changed the title memory leak java <-> javascript memory leak java <-> javascript when java returns []array May 2, 2019
@patricklx
Copy link
Author

@vtrifonov can you also have a looks at this one? its a huge issue for us. We have bluetooth connected to a few devices that send many events

@vtrifonov
Copy link
Contributor

@patricklx what tool did you use to take and compare the memory snapshots?

@patricklx
Copy link
Author

@vtrifonov I used the chrome devtools memory snapshots

@vtrifonov
Copy link
Contributor

We found a problem when creating Array Wrappers which seems to leak memory because of the ObjectTemplates being created every time. However arrays need more memory than a string as we attach some callbacks to them so that they can work in the JS.

@vtrifonov vtrifonov added this to the 5.4.0 milestone May 7, 2019
@patricklx
Copy link
Author

thanks. we tried out the latest snapshot, and memory usage is quite stable!
We had some issues with the tns build android with that new runtime though, we have to run tns build twice, seems some files are not integrated into the apk as resources correctly at first time build. e.g_: app/App_Resources/Android/src/main/res/values/nativescript_google_maps_api.xml

@vhristov5555
Copy link

Could you please try to delete platforms folder and try to build it again. If you could reproduce the problem could please open a new issue with some steps to reproduce it(e.g. files missing) so we could be able to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants