{ "id": "136864", "key": "TIMOB-17740", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "16593", "description": "Release 4.0.0", "name": "Release 4.0.0", "archived": false, "released": true, "releaseDate": "2015-05-21" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2014-12-05T21:39:34.000+0000", "created": "2014-09-19T03:02:37.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "3.4.0", "TCSupport", "release-3.3.0", "release-3.4.0" ], "versions": [ { "id": "15972", "description": "Release 3.4.0", "name": "Release 3.4.0", "archived": false, "released": true, "releaseDate": "2014-09-28" } ], "issuelinks": [ { "id": "43445", "type": { "id": "10000", "name": "Blocks", "inward": "is blocked by", "outward": "blocks" }, "inwardIssue": { "id": "140533", "key": "TIMOB-18096", "fields": { "summary": "iOS: Proxies not being released", "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" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2015-01-19T19:39:14.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": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "h4. Problem Description\r\nWhen aborting a file upload the file that was loaded into ram is kept in ram. The ram does not get cleared unless the upload is completed. So every file thats uploaded and aborted is being kept in active ram on the device. \r\n\r\nIf a user uploads a file and aborts the upload multiple times ram usage becomes very high and will cause the app to crash. This did not happen with release-3.2.3 the ram would get cleared when the upload was aborted. \r\n\r\nWhen watching instruments while preforming a upload you can watch ram using spike on each upload but never be released.\r\n\r\n\r\nh4. Steps to reproduce\r\n1. Create new mobile project (classic titanium)\r\n2. Please copy the Attached file to the Resources directory. \r\n3. Paste the Sample Code to app.js ( to test with large upload file that will automatically abort after 2.5 seconds) :\r\n{code:title=app.js|borderStyle=solid}\r\nvar win = Titanium.UI.createWindow({backgroundColor:'#fff',layout:'vertical'});\r\n \r\nvar ind = Titanium.UI.createProgressBar({\r\n width:200,\r\n height:50,\r\n min:0,\r\n max:1,\r\n value:0,\r\n top:10,\r\n message:'Progress',\r\n font:{fontSize:12, fontWeight:'bold'},\r\n color:'#888'\r\n});\r\n \r\nwin.add(ind);\r\nind.show();\r\n\r\naddButton({\r\n title: 'Upload File',\r\n callback: function(e) {\r\n ind.value = 0;\r\n \r\n \t\tvar canceled = false;\r\n var file = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,'sunset.jpg');\r\n var uploadfile = file.read();\r\n \r\n var httpClient = Titanium.Network.createHTTPClient(); \r\n httpClient.setTimeout(12000);\r\n \r\n var uploadStartTime = new Date().getTime();\r\n \r\n httpClient.onsendstream = function(e){ \r\n ind.value = e.progress;\r\n // The upload is cancelled at 25%\r\n if (e.progress >= 0.25) {\r\n \thttpClient.abort();\r\n \thttpClient = null;\r\n }\r\n };\r\n \r\n httpClient.open('POST', 'http://cachefly.cachefly.net'); \r\n httpClient.send({media:uploadfile});\r\n }\r\n});\r\n\r\naddButton({\r\n title: 'Open Window',\r\n callback: function(e) {\r\n openWindow();\r\n }\r\n});\r\n \r\nfunction addButton(args) {\r\n var b1 = Ti.UI.createButton({\r\n title: args.title,\r\n top: 40\r\n });\r\n b1.addEventListener('click', args.callback);\r\n win.add(b1);\r\n}\r\n \r\nfunction openWindow() {\r\n var win2 = Ti.UI.createWindow({\r\n backgroundColor: 'blue',\r\n layout:'horizontal'\r\n });\r\n for (var i=0;i<500;i++) {\r\n var v = Ti.UI.createView({\r\n backgroundColor: 'red',\r\n height: 50, width: 50,\r\n top:5, left:5\r\n });\r\n \r\n var l = Ti.UI.createLabel({text: i})\r\n v.add(l);\r\n win2.add(v);\r\n }\r\n win2.addEventListener('click', function() {\r\n win2.close();\r\n });\r\n win2.open();\r\n}\r\n\r\nwin.open();\r\n{code}\r\n\r\n", "attachment": [ { "id": "51433", "filename": "sunset.jpg", "author": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-09-19T03:02:37.000+0000", "size": 7712782, "mimeType": "image/jpeg" } ], "flagged": false, "summary": "iOS: Aborting upload causes file to stay in RAM", "creator": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "OS X 10.10 Titanium Studio, build: 3.4.0.201409161931 iOS 8 xCode 6\r\n\r\nCLI version 3.4.0-beta, \r\nTitanium SDK version 3.4.0.v20140905152516 \r\niOS 8.0. Device iPod 5G 8.0.", "closedSprints": [ { "id": 258, "state": "closed", "name": "2014 Sprint 24 SDK", "startDate": "2014-11-24T22:28:25.425Z", "endDate": "2014-12-06T01:00:00.000Z", "completeDate": "2014-12-08T17:21:15.171Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "324994", "author": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Did some more on device testing of this with a iPhone 5s and iPhone 6. When watching with instruments the ram usage spikes on each upload test and isn't released when aborted and eventually with crash the app with a NSAllocateMemoryPages error. \r\n\r\nIf I build the same code with TI SDK 3.2.3 this is not the case, the file is never even put into ram on the upload I can do it hundreds of times with no memory issues at all. ", "updateAuthor": { "name": "dlewis23", "key": "dlewis23", "displayName": "Donovan Lewis", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-09-22T19:57:51.000+0000", "updated": "2014-09-22T19:57:51.000+0000" }, { "id": "326351", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Removing iOS 8 label as I don't believe this is iOS 8 related", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-09-30T16:26:58.000+0000", "updated": "2014-09-30T16:26:58.000+0000" }, { "id": "333702", "author": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "body": "There is a memory leak in master (TIMOB-18096) that needs to be resolved before this one.", "updateAuthor": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-11-25T20:41:58.000+0000", "updated": "2014-11-25T20:41:58.000+0000" }, { "id": "333950", "author": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR\r\nmaster: https://github.com/appcelerator/titanium_mobile/pull/6404\r\n\r\nh5. Testing instructions\r\nBecause of the way garbage collection is now handled in JSCore (TIMOB-18096) it will be tricky to see that this fixed the issue. Follow the instructions below.\r\n\r\n# Download the image attached to this ticket and put it in your *Resources* directory.\r\n# Copy the example code seen in the description of this ticket and put it in your *app.js*.\r\n# Build your app.\r\n# Open the generated Xcode project found in *YourApp/build/iphone/*.\r\n# In Xcode click and hold on the *Run* button at the top left (It looks like a \"play\" button on a music player). You will see a dropdown, select *Profile* and release your click. Once Xcode builds the app, it will launch *Instruments*.\r\n# Instruments will prompt you for a profiling template. Pick *Allocations* and then click *Choose*.\r\n# In Instruments click the *Record* button at the top left (It looks like a \"record\" button).\r\n# Once your app starts notice the level of the blue graph, that is the memory used by the app.\r\n# In Instruments you will also see a list of allocations, at the top right of this list there is a text area, add the text \"proxy\".\r\n# Now you should now only see 3 proxies in the allocations list.\r\n# In your app click *Upload File* and notice the memory usage grow.\r\n# You will also see a couple more proxies in the allocations list, make a note of *TiNetworkHTTPClientProxy*.\r\n# At this point the memory usage will stay the same and it will look like this ticket is not actually fixed. We just need to create some memory pressure so garbage collection will run and we can see what that memory is actually being released.\r\n# In your app click *Open Window* (the app may be slow as it opens the window and adds 500 views to it).\r\n# Once the window is open, click anywhere on the window to close it.\r\n# It may be necessary to repeat this process of opening and closing the window a couple times before you see the memory usage of the app drop.\r\n# You will also see *TiNetworkHTTPClientProxy* disappear from the allocations list. This means that it has been garbage collected and is no longer in memory.\r\n", "updateAuthor": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-11-26T22:31:51.000+0000", "updated": "2014-11-26T22:31:51.000+0000" }, { "id": "339738", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "Verified fix on:\r\n\r\nMac OSX 10.10.1\r\nAppcelerator Studio, build: 3.4.1.201410281743\r\nTitanium SDK build: 3.6.0.v20150119054128\r\nTitanium CLI, build: 3.4.1\r\nAlloy: 1.5.1\r\nXcode 6.1.1\r\niPhone 6 Plus (8.1.1), iPhone 5s (8.0.2)\r\n\r\nWhen the file upload is aborted and memory pressure is created the proxy relating to the file upload is collected and removed form memory.\r\n\r\nClosing ticket.", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2015-01-19T19:39:06.000+0000", "updated": "2015-01-19T19:39:06.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }