{ "id": "131658", "key": "AC-1339", "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": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2014-07-09T22:19:01.000+0000", "created": "2014-06-12T20:55:46.000+0000", "labels": [ "android", "httpclient", "leak", "memory" ], "versions": [], "issuelinks": [], "assignee": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "updated": "2016-03-08T07:37:44.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 noticed lots of HttpClientProxy leaks in our Android application. We double checked our code, ran some tests, profiled the same code base on iOS (it was fine on iOS). Eventually we realized the the HTTPClient object is leaking only when there are concurrent xhr requests.\r\n\r\nTest 1 (Leaks)\r\n------------------\r\n\r\nI built a test case and profiled it to confirm our conclusion. In test one, the app will send 20 concurrent HTTP requests. When profiled, it will show that all the HTTPClientProxy objects were leaked, even after invoking GC multiple times.\r\n\r\n\"20 instances of \"ti.modules.titanium.network.HTTPClientProxy\", loaded by \"dalvik.system.PathClassLoader @ 0xb1083270\" occupy 5,327,960 (28.38%) bytes.\"\r\n\r\nTest 2 (Doesn't Leak)\r\n----------------------------\r\n\r\nWhile with test 2, the requests are queued and sent one at a time (100ms delay between every response and next request). The profile result showed that none of the HTTPClientProxy objects were leaked.\r\nI read numerous posts on this forum and most of them were old (from 1.8 days). I'm running my tests on version 3.2.3. Android 4.3.2.\r\n\r\nTest code below:\r\n\r\nfunction xhrRequest(callback) {\r\n var xhr = Ti.Network.createHTTPClient({\r\n timeout : 5000,\r\n cache : false,\r\n onload : function(e) {\r\n if (callback) {\r\n callback();\r\n }\r\n }\r\n });\r\n \r\n xhr.open('POST', 'https://www.yahoo.com/');\r\n xhr.send();\r\n}\r\n \r\nfunction xhrRequestTest1(tests, callback) {\r\n var completed = 0;\r\n for (var i=0;i