Project: titanium
Issue TIMOB-17740: iOS: Aborting upload causes file to stay in RAM
h4. Problem Description When 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. If 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. When watching instruments while preforming a upload you can watch ram using spike on each upload but never be released. h4. Steps to reproduce 1. Create new mobile project (classic titanium) 2. Please copy the Attached file to the Resources directory. 3. Paste the Sample Code to app.js ( to test with large upload file that will automatically abort after 2.5 seconds) : {code:title=app.js|borderStyle=solid} var win = Titanium.UI.createWindow({backgroundColor:'#fff',layout:'vertical'}); var ind = Titanium.UI.createProgressBar({ width:200, height:50, min:0, max:1, value:0, top:10, message:'Progress', font:{fontSize:12, fontWeight:'bold'}, color:'#888' }); win.add(ind); ind.show(); addButton({ title: 'Upload File', callback: function(e) { ind.value = 0;	var canceled = false; var file = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,'sunset.jpg'); var uploadfile = file.read(); var httpClient = Titanium.Network.createHTTPClient(); httpClient.setTimeout(12000); var uploadStartTime = new Date().getTime(); httpClient.onsendstream = function(e){ ind.value = e.progress; // The upload is cancelled at 25% if (e.progress >= 0.25) {	httpClient.abort();	httpClient = null; } }; httpClient.open('POST', 'http://cachefly.cachefly.net'); httpClient.send({media:uploadfile}); } }); addButton({ title: 'Open Window', callback: function(e) { openWindow(); } }); function addButton(args) { var b1 = Ti.UI.createButton({ title: args.title, top: 40 }); b1.addEventListener('click', args.callback); win.add(b1); } function openWindow() { var win2 = Ti.UI.createWindow({ backgroundColor: 'blue', layout:'horizontal' }); for (var i=0;i<500;i++) { var v = Ti.UI.createView({ backgroundColor: 'red', height: 50, width: 50, top:5, left:5 }); var l = Ti.UI.createLabel({text: i}) v.add(l); win2.add(v); } win2.addEventListener('click', function() { win2.close(); }); win2.open(); } win.open(); {code}
Story points: 8