[AC-1559] How to Reduce/Clear Android Heap Memory Size???
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Not Our Bug |
Resolution Date | 2014-06-30T02:00:28.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Sattanathan |
Assignee | Mauro Parra-Miranda |
Created | 2014-06-04T02:52:37.000+0000 |
Updated | 2016-03-08T07:38:01.000+0000 |
Description
Hi,
We created app for Sales&Inventory Management System. This app having more no of screens so we used Multiple Windows concepts. our app working perfectly But we have MEMORY issue. Whenever i open the new window the Memory size was increased After Closed window i clear all the children's components & put 'null'. Device HEAP Memory size is not reduced. I have used below functions for clear children’s:
.
.
.
windowClosed : function(){
Controller.prototype. deAllocate(win);
},
deAllocate : function(win) {
var length = win.children.length;
for (var ctr = length-1; ctr >= 0; ct--) {
var childView = view.children[ctr];
if (childView != undefined || childView != null) {
Ti.API.info(‘deAllocate -> ‘ + childView);
Controller.prototype.deAllocateChildView(childView);
win.remove(childView);
childView = null;
}
childView = null;
}
win.close();
win = null;
},
deAllocateChildView : function(view){
var length = view.children.length;
for (var ctr = length-1; ctr >= 0; ctr--) {
var childView = view.children[ctr];
if (childView != undefined || childView != null) {
Ti.API.info(‘deAllocateChildView -> ‘ + childView);
Controller.prototype.deAllocateChildView(childView);
view.remove(childView);
childView = null;
}
childView = null;
}
view = null;
},
.
.
.
I checked with logcat all the UI components are removed. but heap memory size is not reduced. whenever i opened new window the heap memory size is increasing. Once its reached 48MB my app will through OUT OF MEMORY exception is coming and app EXIT we need to restart the app.
my TiApp.xml file:
http://schemas.android.com/apk/res/android">
41943040
41943040
17
distribution
true
dp
false
true
Is there any way to reduce heap memory, can you help me to fix this problem…
Thanks
Hello! All the memory is managed by Android. In short: It will keep memory assigned to your app (even if you do this nice cleaning), since it will use both CPU and battery to do so. What it does is, it leaves the memory untouched, until the memory is needed. More info about this, here; http://forum.xda-developers.com/showthread.php?t=897823 Best Regards!