hi, i just finished read this article about avoid memory leaks: https://wiki.appcelerator.org/display/guides2/Managing+Memory+and+Finding+Leaks in my application i have a few libraries that exports windows or pickers. like example: controluicombobywin.js
function controlUiComboByWin(indata, sdata, callback,refWindow, refId, pickerRef,callbackChangeVal) { callbackChangeVal = callbackChangeVal || null; var searchs = require('/lib/searchs'); this.id = refId; this.dataCbx = indata; var that = this; var containerPicker = Ti.UI.createView({ width: sdata.listViewWidth, height:Ti.UI.SIZE, top: sdata.pickerTop, touchEnabled: true, bubbleParent:true, backgroundColor:'#FFFFFF', borderColor:'#DAD6DA', borderWidth : 1, }); if(sdata.orientation == 'right'){ containerPicker.right = sdata.pickerPosition; }else if(sdata.orientation == 'left'){ containerPicker.left = sdata.pickerPosition; }else{ containerPicker.center = sdata.pickerPosition; } var picker = Ti.UI.createTextField({ color: '#817F81', value: sdata.valuePicker, editable: false, touchEnabled: true, font: { fontSize: sdata.fontSize, fontFamily: sdata.fontFamily }, left: '0dp', width:'80%', height:'100%', wordWrap:true, textAlign:'left', verticalAlign: Ti.UI.TEXT_VERTICAL_ALIGNMENT_CENTER, backgroundColor:'transparent', borderRadius:3, backgroundPaddingLeft: 30, backgroundPaddingRight: 30 }); imageSpin = Ti.UI.createImageView({ image:'/images/spin.png', right: '7dp', touchEnabled: true, width:'20dp', height:'20dp' }); containerPicker.add(imageSpin); containerPicker.add(picker); containerPicker.addEventListener('click',function(e){ e.bubbles = true; try{ var modal = require('/lib/modalWindows').modalWin; containerPicker.setBorderColor('#DAD6DA'); var arrdata = that.dataCbx; var tools = new searchs.Tools(); var sizeWin = tools.calculateWidthWin(20); var popupWin = new modal(arrdata, sdata, picker, "picker","80%", sizeWin, null, null, that,callbackChangeVal); var _deviceE = tools.osDevice(); if(_deviceE == "android") popupWin.open({activityEnterAnimation: Ti.Android.R.anim.fade_in, activityExitAnimation: Ti.Android.R.anim.fade_out, modal: true}); else popupWin.open({modal: true}); modal = null; arrdata = null; tools = null; sizeWin = null; popupWin = null; _deviceE = null; }catch(e){ tools.nativeNotification(L('errorAction')); }; }); picker.addEventListener('change', function(e){ e.bubbles = true; if(pickerRef){ if(callback){ var data = callback(that.id); pickerRef.changeValueRef(''); pickerRef.setdataCbx(''); pickerRef.dataCbx = data; pickerRef.id = data[0].id; pickerRef.setrefId(data[0].id); pickerRef.statusChange(); } } }); refWindow.add(containerPicker); this.changeValueRef = function(value) {//change value name picker.value = value; }; this.GetID = function(value){ return this.id; }; this.openWin = function(){ try{ containerPicker.setBorderColor('#DAD6DA'); var modal = require('/lib/modalWindows').modalWin; var arrdata = that.dataCbx; var tools = new searchs.Tools(); var _deviceE = tools.osDevice(); var sizeWin = tools.calculateWidthWin(20); var popupWin = new modal(arrdata, sdata, picker, "picker","80%", sizeWin, null, null, that,callbackChangeVal); if(_deviceE == "android") popupWin.open({activityEnterAnimation: Ti.Android.R.anim.fade_in, activityExitAnimation: Ti.Android.R.anim.fade_out, modal: true}); else popupWin.open({modal: true}); }catch(e){ tools.nativeNotification(L('errorAction')); }; }; this.refValue = function(){ return picker.value; }; this.changeStatus = function(){ containerPicker.setBorderColor('#FF2626'); }; } function getdataCbx(){ return this.dataCbx; } function setdataCbx(data){ this.dataCbx = data; } function getrefId(){ return this.id; } function setrefId(id){ this.id = id; } function setText(name){ this.changeValueRef(name); } function showWin(){ this.openWin(); }; function getrefValue(){ return this.refValue(); }; function statusChange(){ this.changeStatus(); }; controlUiComboByWin.prototype.showWin = showWin; controlUiComboByWin.prototype.setText = setText; controlUiComboByWin.prototype.getdataCbx = getdataCbx; controlUiComboByWin.prototype.setdataCbx = setdataCbx; controlUiComboByWin.prototype.getrefId = getrefId; controlUiComboByWin.prototype.setrefId = setrefId; controlUiComboByWin.prototype.statusChange = statusChange; controlUiComboByWin.prototype.getrefValue = getrefValue; module.exports = controlUiComboByWin;in each function that references objects once time its not used i must assigned null value? like:
e.bubbles = true; try{ var modal = require('/lib/modalWindows').modalWin; containerPicker.setBorderColor('#DAD6DA'); var arrdata = that.dataCbx; var tools = new searchs.Tools(); var sizeWin = tools.calculateWidthWin(20); var popupWin = new modal(arrdata, sdata, picker, "picker","80%", sizeWin, null, null, that,callbackChangeVal); var _deviceE = tools.osDevice(); if(_deviceE == "android") popupWin.open({activityEnterAnimation: Ti.Android.R.anim.fade_in, activityExitAnimation: Ti.Android.R.anim.fade_out, modal: true}); else popupWin.open({modal: true}); modal = null; arrdata = null; tools = null; sizeWin = null; popupWin = null; _deviceE = null; }catch(e){ tools.nativeNotification(L('errorAction')); };is that correct or is another way to avoid memory leaks? thanks in advance