GitHub Issue | n/a |
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-12-07T08:58:15.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.1.0 |
Components | Android |
Labels | android, leak, listview, memory |
Reporter | Mateus Kamoei |
Assignee | Gary Mathews |
Created | 2016-07-28T19:09:46.000+0000 |
Updated | 2017-01-23T16:37:39.000+0000 |
Problem: After closing a window with a listView inside its activity never gets finished causing a memory leak. This occurs even if the listView has no elements or listeners in its template. Eventually all this leaked memory causes the application to crash.
Steps to reproduce:
1. Start the application (attached listViewMemoryLeak.js script)
2. Create a heap dump in DDMS
3. Tap the 'ListView' or 'ListView empty' buttons
4. Tap the back button
5. Cause GC
6. Create a second heap dump in DDMS
7. Do a comparison of the two heap dumps with Eclipse Memory Analyzer. The second heap dump has multiple new and living objects compared to the first heap dump. If you tap the 'View' or 'ScrollView' buttons instead and repeat the same process you'll notice that this does not occur.
Hello ! I took a look at the code and this is not problem from our sdk, this is happening because you are not closing the windows, each time you open a window, it creates a new instance and if you open the window again it is creating a new one. To avid this you can close all windows before open a new one, to close a window, you only need to do it the same way you open it, just add in the code
so you can close all the windows before open new ones in your events.
Hi Ricardo, Thanks for the quick reply! So what you are suggesting is to add an androidback event for every window opened that calls window.close()? Also I still don't understand why there is a difference in the number of activities seen on the heap dump. In the following heap dump screen shot, in the attached test app I just tapped the "View" button and then tapped the back button. You can see there is only *1 TiActivity object*. [http://imgur.com/jJKxq3J] In this next heap dump screen shot, in the attached test app I tapped the "ListView" button and then tapped the back button. The result is there are *2 TiActivity objects* remaining. [http://imgur.com/3oZOV8v] I closed the app before both tests executions.
Attached two new files: - memory_leak.pdf: steps to reproduce the issue; - app.js: new sample code.
Hello ! The ticket is moved, do not remember that the main issue is that exists a memory leak after close a window with a listview inside.
Using the monitor in IntelliJ, it states that clicking any of the buttons will cause leaked activities. The leak isn't attributed to only those activities containing the listview. For some reason, the activities aren't being destroyed.
master: https://github.com/appcelerator/titanium_mobile/pull/8616
Verified fixed using the test code provided by [~gmathews] in https://github.com/appcelerator/titanium_mobile/pull/8616 was able to see number of objects and heap size decrease. To test Garys test case I took the following steps: 1. Start the application 2. Create a heap dump in DDMS 3. Tap the
TI.UI.ListView
orTI.UI.View empty
buttons 4. Tap the back button 5. Cause GC 6. Create a second heap dump in DDMS 7. Repeat process on the latest SDK build and see ifTi.UI.ListView
stops leaking memory *Environment*