{ "id": "97968", "key": "AC-2735", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "8", "description": "", "name": "Needs more info" }, "resolutiondate": "2012-07-31T05:44:48.000+0000", "created": "2012-07-25T07:05:32.000+0000", "labels": [ "android", "scrollview" ], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:47:37.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "I am trying to add more than 500 elements into a ScrollView from a db with a loop on Android.The app always crashes with a little more than 500 elements added with the following error message:\r\n{code}\r\nD/dalvikvm( 8296): GC_CONCURRENT freed 1200K, 23% free 7569K/9799K, paused 2ms+31ms\r\nE/dalvikvm( 8296): JNI ERROR (app bug): local reference table overflow (max=512)\r\nW/dalvikvm( 8296): JNI local reference table (0x21e410) dump:\r\nW/dalvikvm( 8296): Last 10 entries (of 512):\r\nW/dalvikvm( 8296): 511: 0x413d7630 java.lang.String \"fontWeight\"\r\nW/dalvikvm( 8296): 510: 0x413d75d0 java.util.HashMap\r\nW/dalvikvm( 8296): 509: 0x413d7590 java.lang.String \"font\"\r\nW/dalvikvm( 8296): 508: 0x413d7320 java.util.HashMap\r\nW/dalvikvm( 8296): 507: 0x413d7308 java.lang.Object[] (1 elements)\r\nW/dalvikvm( 8296): 506: 0x413d7298 java.lang.String \"app://ui/common/... (29 chars)\r\nW/dalvikvm( 8296): 505: 0x413c89d8 java.lang.String \"50dp\"\r\nW/dalvikvm( 8296): 504: 0x413759d0 java.lang.String \"50dp\"\r\nW/dalvikvm( 8296): 503: 0x41337138 java.lang.String \"50dp\"\r\nW/dalvikvm( 8296): 502: 0x41377488 java.lang.String \"50dp\"\r\nW/dalvikvm( 8296): Summary:\r\nW/dalvikvm( 8296): 1 of java.lang.Object[] (1 elements)\r\nW/dalvikvm( 8296): 507 of java.lang.String (507 unique instances)\r\nW/dalvikvm( 8296): 2 of java.util.HashMap (2 unique instances)\r\nW/dalvikvm( 8296): 1 of org.appcelerator.kroll.runtime.v8.V8Runtime\r\nW/dalvikvm( 8296): 1 of org.appcelerator.titanium.proxy.ActivityProxy\r\nE/dalvikvm( 8296): Failed adding to JNI local ref table (has 512 entries)\r\n{code}\r\nIt seems to be an Android specific problem with the local references in some JNI call not deleted. Unfortunately I can't test it on an iPhone.", "attachment": [], "flagged": false, "summary": "Android: ScrollView does not allow more than 512 elements", "creator": { "name": "dominik.spengler", "key": "dominik.spengler", "displayName": "Dominik Spengler", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "dominik.spengler", "key": "dominik.spengler", "displayName": "Dominik Spengler", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium Studio Version: 2.1.0\r\nAndroid SDK Tools, revision 20\r\nAndroid SDK Platform-tools, revision 12\r\n", "comment": { "comments": [ { "id": "210650", "author": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hello,\r\n\r\nWhat kind of elements are you adding? I tried adding 1000 labels, and it works fine on my device (Samsung Galaxy S2), as well as on the Emulator v4.0.3 and v2.3.3.\r\n\r\nThere might be a memory issue, if you are adding complex elements to the view; can you post a sample code?", "updateAuthor": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-07-31T05:34:55.000+0000", "updated": "2012-07-31T05:34:55.000+0000" }, { "id": "211463", "author": { "name": "dominik.spengler", "key": "dominik.spengler", "displayName": "Dominik Spengler", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi,\r\n\r\nthanks for your reply.\r\n\r\nI thought about it being a memory issue as well, but in that case the JNI error seems a bit wierd.\r\nMy setup is a bit more complicated as I add two labels and an image to the ScrollView 500+ times. However I also get this error when adding only labels.\r\n\r\nI am using the following code to add elements:\r\n{code}\r\n// function to create row elements. To keep it shorter this snippet only adds one label as this does not work either.\r\nfunction makeRow(product) {\r\n\tvar row = Ti.UI.createView(product);\r\n\r\n\trow.height = '50dp';\r\n\tvar text = Ti.UI.createLabel({\r\n\t\ttext : product.title,\r\n\t\trow : row,\r\n\t});\r\n\r\n\ttext.addEventListener('click', function(e) {\r\n\t\tself.fireEvent('itemSelected', detailFunction(row));\r\n\t});\r\n\treturn row;\r\n};\r\n\r\n// db loop\r\nvar db = Ti.Database.open(Ti.App.Properties.getString('db-name'));\r\nvar products = db.execute('SELECT name FROM products ORDER BY name ASC');\r\n\r\nTi.API.log('starting to load DB');\r\nwhile(products.isValidRow()) {\r\n\tvar product_name = products.fieldByName('name');\r\n\r\n\tvar row = {\r\n\t\ttitle : product_name,\r\n\t};\r\n\tscrollView.add(makeRow(row));\r\n\tproducts.next();\r\n}\r\nproducts.close();\r\ndb.close();\r\nTi.API.log('finished loading DB');\r\n{code} \r\nIt has been simplified but I can confirm the above code not working neither on the 2.3.3 emulator nor on the 4.0.3 emulator.\r\n\r\nI am using Android SDK version 2.2.\r\n", "updateAuthor": { "name": "dominik.spengler", "key": "dominik.spengler", "displayName": "Dominik Spengler", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-04T04:05:21.000+0000", "updated": "2012-08-04T04:05:21.000+0000" }, { "id": "283572", "author": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hello,\r\n\r\nI tested this issue with the test code below. I can’t reproduce this issue in Ti SDK 3.1.3GA. Please install the latest SDK and test your app. If you continue to get error, please send us a test case with steps to reproduce. \r\n\r\nh5. Testing Environment:\r\nTi CLI 3.3.0\r\nTitanium SDK: 3.1.3.GA \r\nAndroid Device 2.3.3\r\n\r\n\r\n\r\nh5. Test Code\r\n\r\napp.js\r\n{code}\r\n function makeid() {\r\n\tvar text = \"\";\r\n\tvar possible = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\r\n\r\n\tfor (var i = 0; i < 15; i++)\r\n\t\ttext += possible.charAt(Math.floor(Math.random() * possible.length));\r\n\r\n\treturn text;\r\n}\r\n\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor : 'white',\r\n\texitOnClose : true,\r\n\tfullscreen : false,\r\n\ttitle : 'ScrollView Demo'\r\n});\r\n\r\nvar scrollView = Ti.UI.createScrollView({\r\n\tcontentWidth : 'auto',\r\n\tcontentHeight : 'auto',\r\n\tshowVerticalScrollIndicator : true,\r\n\tshowHorizontalScrollIndicator : true,\r\n\tlayout : 'vertical',\r\n});\r\n\r\nfor (var i = 0, j = 550; i < j; i++) {\r\n\r\n\tscrollView.add(Ti.UI.createLabel({\r\n\t\ttext : makeid() + ' ' + i,\r\n\t\tcolor : '#000',\r\n\t\theight : 40,\r\n\t}));\r\n\r\n};\r\nwin.add(scrollView);\r\nwin.open();\r\n\r\n{code}\r\n \r\n\r\nh5. Steps to Test\r\n\r\n1. Create a new project\r\n2. Update app.js file \r\n4. And run this project with testing environment\r\n\r\nh5. Expected Result \r\n\r\n550 rows will display on the screen\r\n\r\n\r\n\r\nThanks\r\n", "updateAuthor": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-12-10T18:12:25.000+0000", "updated": "2013-12-11T21:06:40.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }