Titanium JIRA Archive
Appcelerator Community (AC)

[AC-3020] Memory leak that is easily reproductible on android with table views and images

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2011-12-29T05:41:10.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid, image, memory, tableview
ReporterRomain
AssigneePaul Dowsett
Created2011-11-07T09:02:03.000+0000
Updated2016-03-08T07:48:03.000+0000

Description

Hi, We have a memory leak that is easily reproductible on android with table views and images. We have reproduced this issue with: - Titanium version: 1.7.3, 1.7.5, 1.8.0.v20111106143455 - Google APIs Android 2.2, Google APIs Android 2.3.3 - a Samsung Galaxy S (android 2.3.6), a Google Nexus S (android 2.3.6) and an HTC Desire HD (android 2.3.3) *THE ISSUE:* When we add an image to a row (with 'leftImage' or with an 'imageView'), and we scroll up and down continuously during 20 seconds, our app slows down and eventually crashes. As you can see in the logs, the free memory decrease until we have a warning _Clamp target GC heap from 33.070MB to 32.000MB_ and later, the error _11-07 17:14:27.167: ERROR/GraphicsJNI(18626): VM won't let us allocate 103600 bytes_ that will generate the final issues: - some images of the table view disappear randomly - the table view scrolls slower and slower - if you continue the process, the app will crash with a OutOfMemoryError (11-07 17:14:45.781: ERROR/TiAnalyticsSvc(18626): java.lang.OutOfMemoryError). The image used in the rows for the example code is taken from the web at this url (http://www.sosandroid.fr/andropress/wp-content/uploads/2009/06/appcelerator-titanium1.png), its size is "175 × 148, 14KB". When we check the headers of the request used to retrieve the url, we can see that it has cache directives (Cache-Control:max-age=604800), so we can suppose that it is cached by android. *ADDITIONAL INFORMATION:* - this issue only happens on android - this issue only happens if we scroll the table view: A little scrollable table view will crash later, but will crash. A table view which doesn't scroll won't crash - if you use bigger images, the app will crash much sooner (this is how we identified the issue) *FILES ATTACHED:* - app.js: code example - logs.rtf: logs of the crash

Attachments

FileDateSize
app.js2011-11-07T09:02:03.000+0000451
logs.rtf2011-11-07T09:02:03.000+000021834

Comments

  1. Romain 2011-11-08

    As precised in this [Q&A](http://developer.appcelerator.com/question/127884/memory-leak-that-is-easily-reproductible-on-android-with-table-views-and-images#222768), a workaround of this issue is to precise a *className* for the row. I can't explain why, but it works. Nevertheless, maybe you should spend time on this big issue (we have lost so much time on it, and I don't think that it is normal to have to make a workaround like this :/) Thanks in advance, Romain
  2. Paul Dowsett 2011-12-29

    Romain It is necessary to set a unique [Titanium.UI.TableViewRow](http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.TableViewRow-object#properties) className property on each set of rows that has a different layout. As this seems to have been omitted from the latest set of guides, I have raised TIMOB-6921 to address it. Cheers
  3. Shak Hossain 2013-12-28

JSON Source