Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Nulling elements has failed

$
0
0

In order to free memory in my application, i tried to null elements which were written in an xml file(detailsoireescreen.xml ) and added to a View.

this is the detailsoireescreen.xml file

<Alloy>
    <View>
        <ImageView id="detailsoireeimg" height="110" width="320" top="0" />
        <View id="detsoirenameadress" width="234" height="50" backgroundColor="black" top="110" left="86" borderColor="#C29531" borderWidth="1">
            <ImageView id="locationIcon" image="images/locationIcon.png" top="15" left="11" width="8" height="12" />
            <ImageView id="detailsoireelogo" top="15" left="12" width="8" height="12" />
            <Label id="locatNameLabel"/>
            <Label id="adressLabel" />
            <Label id="CpCityLabel" />
        </View>
        <ImageView id="detailsoireelogo" top="100" left="0" width="90" height="60" borderColor="#C29531" borderWidth="1.5" />
        <ScrollView id="nightScrolView" height="120" width="312" backgroundColor="black" top="170" left="4" borderColor="#C29531" borderWidth="1.5" opacity="0.7">
            <Label id="titleLabel" />
            <Label id="datesLabel" />
            <Label id="descriptLabel" />
        </ScrollView>
        <ImageView id="booknow" image="images/booknow.png" height="30" width="140" top="300" left="90" />
    </View>
</Alloy>
in another controller(basewin.js), i add that view by creating its controller :
////// :: adding addDetailsoireescreen :: ////// ////// ////// ////////
function addDetailsoireescreen(){
    $.mainscreen.detailsoireescreen = Ti.UI.createView({
        id : "detailsoireescreen",
        top:90,
        left:-310,
        width:Ti.UI.SIZE,
        height:Ti.UI.SIZE
    });
    Ti.App.detailsoireescreenCtrl = Alloy.createController('detailsoireescreen');
    $.mainscreen.detailsoireescreen.add(Ti.App.detailsoireescreenCtrl.getView());
    $.mainscreen.add($.mainscreen.detailsoireescreen);
}
exports.addDetailsoireescreen = addDetailsoireescreen;
the add was successful.

Before to null any element i checked if i can access to that element (if this fail i will get "undefined" othrwise i will get the desired object) and i didn't fail to access any element of them(the console log it shown at the end of this question).

if (element == Ti.App.basewinCtrl.mainscreen.detailsoireescreen) {
                Ti.API.info("indexwin.js line 174 --Nulling detailsoireescreen sub-element ");
 
                Ti.API.info("***Ti.App.basewinCtrl.mainscreen.detailsoireescreen : "+Ti.App.basewinCtrl.mainscreen.detailsoireescreen);
                Ti.App.basewinCtrl.mainscreen.detailsoireescreen = null; 
                Ti.API.info("***Ti.App.detailsoireescreenCtrl.detailsoireeimg : "+Ti.App.detailsoireescreenCtrl.detailsoireeimg);
                Ti.App.detailsoireescreenCtrl.detailsoireeimg = null; 
                Ti.API.info("***Ti.App.detailsoireescreenCtrl.detsoirenameadress : "+Ti.App.detailsoireescreenCtrl.detsoirenameadress);
                Ti.App.detailsoireescreenCtrl.detsoirenameadress = null; 
                Ti.API.info("***Ti.App.detailsoireescreenCtrl.locationIcon : "+Ti.App.detailsoireescreenCtrl.locationIcon);
                Ti.App.detailsoireescreenCtrl.locationIcon = null; 
                Ti.API.info("***Ti.App.detailsoireescreenCtrl.detailsoireelogo : "+Ti.App.detailsoireescreenCtrl.detailsoireelogo);
                Ti.App.detailsoireescreenCtrl.detailsoireelogo = null; 
                Ti.API.info("***Ti.App.detailsoireescreenCtrl.locatNameLabel : "+Ti.App.detailsoireescreenCtrl.locatNameLabel);
                Ti.App.detailsoireescreenCtrl.locatNameLabel = null; 
                Ti.API.info("***Ti.App.detailsoireescreenCtrl.adressLabel : "+Ti.App.detailsoireescreenCtrl.adressLabel);
                Ti.App.detailsoireescreenCtrl.adressLabel = null; 
                Ti.API.info("***Ti.App.detailsoireescreenCtrl.CpCityLabel : "+Ti.App.detailsoireescreenCtrl.CpCityLabel);
                Ti.App.detailsoireescreenCtrl.CpCityLabel = null; 
                Ti.API.info("***Ti.App.detailsoireescreenCtrl.detailsoireelogo : "+Ti.App.detailsoireescreenCtrl.detailsoireelogo);
                Ti.App.detailsoireescreenCtrl.detailsoireelogo = null; 
                Ti.API.info("***Ti.App.detailsoireescreenCtrl.nightScrolView : "+Ti.App.detailsoireescreenCtrl.nightScrolView);
                Ti.App.detailsoireescreenCtrl.nightScrolView = null; 
                Ti.API.info("***Ti.App.detailsoireescreenCtrl.titleLabel : "+Ti.App.detailsoireescreenCtrl.titleLabel);
                Ti.App.detailsoireescreenCtrl.titleLabel = null; 
                Ti.API.info("***Ti.App.detailsoireescreenCtrl.datesLabel : "+Ti.App.detailsoireescreenCtrl.datesLabel);
                Ti.App.detailsoireescreenCtrl.datesLabel = null; 
                Ti.API.info("***Ti.App.detailsoireescreenCtrl.descriptLabel : "+Ti.App.detailsoireescreenCtrl.descriptLabel);
                Ti.App.detailsoireescreenCtrl.descriptLabel = null; 
                Ti.API.info("***Ti.App.detailsoireescreenCtrl.booknow : "+Ti.App.detailsoireescreenCtrl.booknow);
                Ti.App.detailsoireescreenCtrl.booknow = null; 
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                //After nulling elements :
                Ti.API.info("after null***Ti.App.basewinCtrl.mainscreen.detailsoireescreen : "+Ti.App.basewinCtrl.mainscreen.detailsoireescreen);
                Ti.API.info("after null***Ti.App.detailsoireescreenCtrl.detailsoireeimg : "+Ti.App.detailsoireescreenCtrl.detailsoireeimg);
                Ti.API.info("after null***Ti.App.detailsoireescreenCtrl.detsoirenameadress : "+Ti.App.detailsoireescreenCtrl.detsoirenameadress);
                Ti.API.info("after null***Ti.App.detailsoireescreenCtrl.locationIcon : "+Ti.App.detailsoireescreenCtrl.locationIcon);
                Ti.API.info("after null***Ti.App.detailsoireescreenCtrl.detailsoireelogo : "+Ti.App.detailsoireescreenCtrl.detailsoireelogo);
 
                Ti.API.info("after null***Ti.App.detailsoireescreenCtrl.locatNameLabel : "+Ti.App.detailsoireescreenCtrl.locatNameLabel);
                Ti.API.info("after null***Ti.App.detailsoireescreenCtrl.adressLabel : "+Ti.App.detailsoireescreenCtrl.adressLabel);
                Ti.API.info("after null***Ti.App.detailsoireescreenCtrl.CpCityLabel : "+Ti.App.detailsoireescreenCtrl.CpCityLabel);
                Ti.API.info("after null***Ti.App.detailsoireescreenCtrl.detailsoireelogo : "+Ti.App.detailsoireescreenCtrl.detailsoireelogo);
 
                Ti.API.info("after null***Ti.App.detailsoireescreenCtrl.nightScrolView : "+Ti.App.detailsoireescreenCtrl.nightScrolView);
                Ti.API.info("after null***Ti.App.detailsoireescreenCtrl.titleLabel : "+Ti.App.detailsoireescreenCtrl.titleLabel);
                Ti.API.info("after null***Ti.App.detailsoireescreenCtrl.datesLabel : "+Ti.App.detailsoireescreenCtrl.datesLabel);
                Ti.API.info("after null***Ti.App.detailsoireescreenCtrl.descriptLabel : "+Ti.App.detailsoireescreenCtrl.descriptLabel);
                Ti.API.info("after null***Ti.App.detailsoireescreenCtrl.booknow : "+Ti.App.detailsoireescreenCtrl.booknow);
                /////end after null : 
 
 
                Ti.App.basewinCtrl.mainscreen.detailsoireescreen = null; 
                Ti.App.detailsoireescreenCtrl = null;
            }

After nulling all elements i tried to check if the nulling was successful so i tried to access these elements again (and expected to get "null" for each one) but i was surprised when i see that all objects (except one which wasn't written in the xml file but was created to add the view (i'm talking about the Ti.App.basewinCtrl.mainscreen.detailsoireescreen which is the $.mainscreen.detailsoireescreen. in the 'basewin.js'

this is the console log :

[INFO] :   indexwin.js line 174 --Nulling detailsoireescreen sub-element
[INFO] :   ***Ti.App.basewinCtrl.mainscreen.detailsoireescreen : [object detailsoireescreen]
[INFO] :   ***Ti.App.detailsoireescreenCtrl.detailsoireeimg : [object detailsoireeimg]
[INFO] :   ***Ti.App.detailsoireescreenCtrl.detsoirenameadress : [object detsoirenameadress]
[INFO] :   ***Ti.App.detailsoireescreenCtrl.locationIcon : [object locationIcon]
[INFO] :   ***Ti.App.detailsoireescreenCtrl.detailsoireelogo : [object detailsoireelogo]
[INFO] :   ***Ti.App.detailsoireescreenCtrl.locatNameLabel : [object locatNameLabel]
[INFO] :   ***Ti.App.detailsoireescreenCtrl.adressLabel : [object adressLabel]
[INFO] :   ***Ti.App.detailsoireescreenCtrl.CpCityLabel : [object CpCityLabel]
[INFO] :   ***Ti.App.detailsoireescreenCtrl.detailsoireelogo : [object detailsoireelogo]
[INFO] :   ***Ti.App.detailsoireescreenCtrl.nightScrolView : [object nightScrolView]
[INFO] :   ***Ti.App.detailsoireescreenCtrl.titleLabel : [object titleLabel]
[INFO] :   ***Ti.App.detailsoireescreenCtrl.datesLabel : [object datesLabel]
[INFO] :   ***Ti.App.detailsoireescreenCtrl.descriptLabel : [object descriptLabel]
[INFO] :   ***Ti.App.detailsoireescreenCtrl.booknow : [object booknow]
[INFO] :   after null***Ti.App.basewinCtrl.mainscreen.detailsoireescreen : null
[INFO] :   after null***Ti.App.detailsoireescreenCtrl.detailsoireeimg : [object detailsoireeimg]
[INFO] :   after null***Ti.App.detailsoireescreenCtrl.detsoirenameadress : [object detsoirenameadress]
[INFO] :   after null***Ti.App.detailsoireescreenCtrl.locationIcon : [object locationIcon]
[INFO] :   after null***Ti.App.detailsoireescreenCtrl.detailsoireelogo : [object detailsoireelogo]
[INFO] :   after null***Ti.App.detailsoireescreenCtrl.locatNameLabel : [object locatNameLabel]
[INFO] :   after null***Ti.App.detailsoireescreenCtrl.adressLabel : [object adressLabel]
[INFO] :   after null***Ti.App.detailsoireescreenCtrl.CpCityLabel : [object CpCityLabel]
[INFO] :   after null***Ti.App.detailsoireescreenCtrl.detailsoireelogo : [object detailsoireelogo]
[INFO] :   after null***Ti.App.detailsoireescreenCtrl.nightScrolView : [object nightScrolView]
[INFO] :   after null***Ti.App.detailsoireescreenCtrl.titleLabel : [object titleLabel]
[INFO] :   after null***Ti.App.detailsoireescreenCtrl.datesLabel : [object datesLabel]
[INFO] :   after null***Ti.App.detailsoireescreenCtrl.descriptLabel : [object descriptLabel]
[INFO] :   after null***Ti.App.detailsoireescreenCtrl.booknow : [object booknow]
For a while i thought that elements wasn't still gabage collected but then i realized that it's wrong and that element's values should be already nulled even they are still not garbage collected yet (their values would be 'undefined' if the GC did its job (is this right ?)) so i came here and asked this question. As i think this is very weird so i tried to clean the app many times before to run it but this didn't change anything.

What is wrong ?! do elements added with an xml never can be nulled ?! Best.


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>