Hi, In my app i load huge data from a web service. First time every thing is okay. I get this logs in the console:
[INFO][dalvikvm-heap( 492)] Grow heap (frag case) to 4.759MB for 924185-byte allocation [INFO][dalvikvm-heap( 492)] Grow heap (frag case) to 5.637MB for 924185-byte allocation [INFO][dalvikvm-heap( 492)] Grow heap (frag case) to 6.225MB for 616128-byte allocation [INFO][dalvikvm-heap( 492)] Grow heap (frag case) to 6.518MB for 1232240-byte allocation [INFO][dalvikvm-heap( 492)] Grow heap (frag case) to 8.281MB for 2464464-byte allocation [INFO][dalvikvm-heap( 492)] Grow heap (frag case) to 9.457MB for 1232240-byte allocation [INFO][dalvikvm-heap( 492)] Grow heap (frag case) to 8.867MB for 1846398-byte allocationMy tableview is filled with the data and every thing is okay. Now when i close my app and start it again, an error will occur:
[INFO][dalvikvm-heap( 492)] Grow heap (frag case) to 11.534MB for 924185-byte allocation [INFO][dalvikvm-heap( 492)] Grow heap (frag case) to 12.388MB for 924185-byte allocation [INFO][dalvikvm-heap( 492)] Grow heap (frag case) to 12.976MB for 616128-byte allocation [INFO][dalvikvm-heap( 492)] Forcing collection of SoftReferences for 1232240-byte allocation [ERROR][dalvikvm-heap( 492)] Out of memory on a 1232240-byte allocation.How can i release the memory. I only have this problem on Android. I think I'll get the error on this line:
var data = JSON.parse(this.responseText);My app is closed by backbutton and the property exitOnClose: true
I tried to release my tableview in the close-event of the window with
this.listWindow.addEventListener('close', function(e) { datasetListView = null; });but that doesn't help.
2 Answers
I have a simple sample app which shows the problem. app.js:
// This is a single context application with mutliple windows in a stack (function() { var Window = require('ui/ApplicationWindow'); new Window().open(); })();ApplicationWindow.js:
//Application Window Component Constructor function ApplicationWindow() { var username = 'xxx'; var password = 'xxx'; var serverURL = 'http://xxx'; //create component instance var self = Ti.UI.createWindow({ backgroundColor:'#ffffff' }); // release components on close self.addEventListener('close', function(e) { Ti.API.info('close event fired'); self.remove(tableView); tableView = null; }); //construct UI var tableView = new Ti.UI.createTableView({ scrollable: true }); self.add(tableView); var json; var xhr = Ti.Network.createHTTPClient({}); xhr.onload = function(e) { Ti.API.info('data received'); var data = JSON.parse(this.responseText); Ti.API.info('data parsed with length '+ data.length); if (data) { }; data = null; }; xhr.open("GET", serverURL); var authstr = 'Basic ' + Titanium.Utils.base64encode(username + ':' + password); xhr.setRequestHeader('Authorization', authstr); xhr.send(); return self; }; //make constructor function the public component interface module.exports = ApplicationWindow;What i do is to send a HTTP-request to get an JSON-String. With every response i get the memory usage grows. First response:
[INFO][TiAPI ( 372)] data received [INFO][dalvikvm-heap( 372)] Grow heap (frag case) to 3.979MB for 964805-byte allocation [INFO][dalvikvm-heap( 372)] Grow heap (frag case) to 4.880MB for 964805-byte allocation [INFO][dalvikvm-heap( 372)] Grow heap (frag case) to 5.494MB for 643208-byte allocation [INFO][dalvikvm-heap( 372)] Grow heap (frag case) to 5.800MB for 1286400-byte allocation [INFO][dalvikvm-heap( 372)] Grow heap (frag case) to 7.640MB for 2572784-byte allocation [INFO][dalvikvm-heap( 372)] Grow heap (frag case) to 8.867MB for 1286400-byte allocation [INFO][dalvikvm-heap( 372)] Grow heap (frag case) to 8.251MB for 1927492-byte allocation [INFO][TiAPI ( 372)] data parsed with length 315Now I close the app with Back-Button. Second response:
[INFO][TiAPI ( 372)] data received [INFO][dalvikvm-heap( 372)] Grow heap (frag case) to 9.646MB for 2572784-byte allocation [INFO][dalvikvm-heap( 372)] Grow heap (frag case) to 10.257MB for 1927492-byte allocation [INFO][TiAPI ( 372)] data parsed with length 315and so on
Hi Alexander, try increasing the memory size of you emulator...as with new installation it keep adding some resources and show problem in installing.... use AVD manager to increase the size of emulator memory..
Your Answer
Think you can help? Login to answer this question!