My env is : Titanium SDK 3.2.1.GA, OS X Mavericks, iOS7, Xcode 5.0.2.
I have an app that download numerous documents from server. After the download memory consumption by the application is on very high level and don't drop. My code is :
download.js
downloadFile : function(showFolder, showId, docType, remoteFileContainer) { var downloadParams = { password : App.applicationManager.globalVariables.password, user_id : App.applicationManager.globalVariables.user_id, username : App.applicationManager.globalVariables.username, pdf : "1" }; var http = this.getHTTPClient(); http.onreadystatechange = function() { if (http.readyState == 4 && http.status == 200){ var file = Ti.Filesystem.getFile(showFolder + Ti.Filesystem.separator + docType, fileName); file.write(this.responseData); } }; http.open("POST", App.applicationManager.serviceDownloadFile, true); http.send(downloadParams); }, getHTTPClient : function() { var client = Ti.Network.createHTTPClient({ timeout : 60 * 1000, validatesSecureCertificate : false, onerror : function(e) { Ti.API.log('Httpclient log. Response: ' + this.responseText + 'Status: ' + this.status); } }); return client; },Can anyone get me some hint about this one? I tried to set client to null (http = null inside if (http.readyState == 4 && http.status == 200)to be GC, also tried httpClient.abort() (was so desperate :).
Thanks in advance.