You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Memory leak when using slide transition on Android (API Level 23) #2741
Did you verify this is a real problem by searching [Stack Overflow]
Yes
Tell us about the problem
In my sample application to show the memory leak issue, I have two pages. On first page there is only button and on tap on that button, we are navigated to page 2. On Page 2, I have a Label in StackLayout.
Now, when we set page transition to 'slide', it is causing a memory leak on Android API Level 23. Memory keep on increasing on transition till OOM. When I tested that on emulator with API Level 21 and 22, It is not causing any memory leak.
Please check the below heap dump taken on API 23 version showing ImageViews being generated on slide transition are remaining in memory.
Attaching the path2gc for this image, which may help you in finding the memory leak root.
When I checked, what these images are, I found that it is creating screenshot of both the pages on navigation. Below are that Images, which are keep on adding in memory on transition.
Also, I found that, it is not releasing Label in Page 2 on transition. So Labels also keep on adding into memory.
Which platform(s) does your issue occur on?
Android
Please provide the following version numbers that your issue occurs with:
CLI: 2.3.0
Cross-platform modules: Tested on both 2.3.0 and 2.4.0-2016-09-16-4127
Runtime(s): tns-android: 2.3.0
Please tell us how to recreate the issue in as much detail as possible.
Actually in my case, the issue happens only when we use "Slide" transition for navigation on Android. It will work fine if you use "Fade" transition. In my sample app I don't have any image. The memory leak happens event when we have only Label in the page.
I tested the given scenario and I was able to reproduce this behavior with Slide transition while navigating and in non-NativeScript Angular2 project. I am attaching here also my sample project, where this problem has been reproduced.
I have tested the sample app with tns-core-modules and tns-core-modules-widgets 2.4.0-2016-10-14-4397 version. Below are the findings.
When I tested this on genymotion emulator (heapSize: 96MB, API: 23), the transition images were not getting cleared till 14 transitions and after that the GC got called and it cleared some memory. After that I continued to do the transitions for around 16 more time, to check it GC is getting called or not..But it didn't call and it threw OOM and app crashed.
When I tested this on device (heapSize: 256MB, API: 23), the transition images were kept on adding on memory till around 165 MB and then GC called and cleared some memory. I keep on doing transitions, and again around 165MB the GC called and cleared some memory. But it is not clearing all the memory. I analysed the heap dump and found that still some transition images are not getting removed from memory.
So I think the issue is still there. Attaching the path2gc for one of the transition image, which may help you for further investigation.
Edit: I also tried to explicitly call GC() on back navigation. But that also didn't help in avoiding memory leak.
Activity
colinskow commentedon Sep 16, 2016
See the discussion at the bottom of #2571. I believe this is already fixed in master. Install
tns-core-modules@nextand test again.colinskow commentedon Sep 16, 2016
Never mind, it looks like you are using the latest release already. I have additional tests for this issue at https://github.com/colinskow/tns-image-test
shripalsoni04 commentedon Sep 17, 2016
@colinskow Thanks for sharing image tests.
Actually in my case, the issue happens only when we use "Slide" transition for navigation on Android. It will work fine if you use "Fade" transition. In my sample app I don't have any image. The memory leak happens event when we have only Label in the page.
tsonevn commentedon Sep 17, 2016
Hi @shripalsoni04,
I tested the given scenario and I was able to reproduce this behavior with
Slidetransition while navigating and in non-NativeScript Angular2 project. I am attaching here also my sample project, where this problem has been reproduced.Regards,
@tsonevn
hshristov commentedon Oct 10, 2016
Fixed with @next version of
tns-core-modulesandtns-core-modules-widgets. Could you please check with them if everything is ok?shripalsoni04 commentedon Oct 15, 2016
Hi @hshristov,
I have tested the sample app with
tns-core-modulesandtns-core-modules-widgets2.4.0-2016-10-14-4397 version. Below are the findings.When I tested this on genymotion emulator (heapSize: 96MB, API: 23), the transition images were not getting cleared till 14 transitions and after that the GC got called and it cleared some memory. After that I continued to do the transitions for around 16 more time, to check it GC is getting called or not..But it didn't call and it threw OOM and app crashed.
When I tested this on device (heapSize: 256MB, API: 23), the transition images were kept on adding on memory till around 165 MB and then GC called and cleared some memory. I keep on doing transitions, and again around 165MB the GC called and cleared some memory. But it is not clearing all the memory. I analysed the heap dump and found that still some transition images are not getting removed from memory.
So I think the issue is still there. Attaching the path2gc for one of the transition image, which may help you for further investigation.
Edit: I also tried to explicitly call GC() on back navigation. But that also didn't help in avoiding memory leak.
Let me know if you want any other information.
hshristov commentedon Oct 18, 2016
Hi @shripalsoni04,
I assume you are using the attached sample in this issue, right?
shripalsoni04 commentedon Oct 18, 2016
Yes. I am using the attached sample application with angular@2.1.0 and nativescript@2.4.0-2016-10-14-4397.
I just pushed the updated package.json to the sample app.
lock commentedon Aug 28, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.