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

how free memory webview alloy

$
0
0

Hello

I have made an application that needs to use webview, because in a store page to display a lot of information, and have different formats. Furthermore the content is dynamic, and consult a local database.

Every time I go to a different page I perform $ destroy ().; Alloy.createController ("") getView () open ()..;

The problem I have is that when I make a test application, after visiting a few pages, the application gives an error of type 9 kiil and stops.

I have read that is subject of memory, and I've looked through the forum if there was any way to free memory once you leave the page, and what I read is that the destroy is not automatically released, but alloy when free garbage needs. In my case not released and the crash application

Is there any way to release the memory of a webview? There are some alterantiva the webView?

view

<Alloy>
    <Window id="h" class="container">
        <Toolbar id="header" platform="ios" borderTop="false" borderBottom="false" top="0">
            <Items>
                <ImageView id="imgBack" class="imgSlider"/>
                <FlexSpace/>
                <Label id="labelWhy" class="unLiteralHeader"/>
                <FlexSpace/>
                <ImageView id="imgMiniLogo" class="imgMiniLogo"/>
            </Items>
        </Toolbar>
        <Button id="btSituacionOff"/>
        <Button id="btAlteracionOn"/>
        <WebView id="webViewWhy"/>
        <Toolbar id="faa" platform="ios" borderTop="false" borderBottom="false" bottom="0">
            <Items>
                <FlexSpace/>
                <Button id="labelFarmaco"/>
                <FlexSpace/>
            </Items>
        </Toolbar>
    </Window>
</Alloy>
controller
try{
 
    var args = arguments[0] || {};
    var htmlSituaciones = "";
 
    function replaceAll( texto ){
 
        var textoRes = texto.replace(",,",",");
        var textoRes = texto.replace(/__RS__/g,","); 
        var n = textoRes.length;
        if ( textoRes.substr(n-1,n) == ",") {
            textoRes = textoRes.substr(0,n-1);
        }
        return textoRes;
    }
    function quitoSituacion( texto ){
        var textoFin = "";
        var mySplitResult = texto.split(",");
        for (var i = 0; i < mySplitResult.length; i++) {
            Titanium.API.info("split: "+mySplitResult[i]);
            if( mySplitResult[i] != "2" && mySplitResult[i] != "1" && mySplitResult[i] != "24" && mySplitResult[i] != "25"
             && mySplitResult[i] != "26" && mySplitResult[i] != "27" ){
                if( textoFin == "" )
                    textoFin = mySplitResult[i];
                else
                    textoFin = textoFin+","+mySplitResult[i];   
            }
        }
        return textoFin;
    }
    $.winGuias.open();
    var tmpDatos = quitoSituacion( Alloy.Globals.valorIn );
    var idSituaciones = replaceAll( tmpDatos );
    try{
        db = Titanium.Database.open('db');
        var sql = "  ";
        Titanium.API.info(sql);
        rows = db.execute( sql );
        while (rows.isValidRow())   
        {
                html= html+"";
            rows.next();
        }
    } catch (SQLiteConstraintException) {
        var error = "Error .: "+SQLiteConstraintException+" sql: "+sql;
        //alert(error);
    }finally{
        if( db != null ){
            db.close();
            db = null;
        }
        if( rows != null ){
            rows.close();
            rows = null;
        }
    }
    if( html == "" )
        html = L('html');
 
    $.webViewWhy.html = html;
 
 
    function voyFarmaco(){
        $.destroy();
        Alloy.createController("").getView().open();
    }
 
    $.imgMiniLogo.addEventListener('click',function()
    {
        Titanium.Platform.openURL("");
    });
    $.imgBack.addEventListener('click',function()
    {
        $.destroy();
        Alloy.createController("").getView().open();
    });
    $.farmaco.addEventListener('click',function(e){
        voy();
    });
    $.labelFarmaco.addEventListener('click',function(e){
        voy();
    });
    $.btSituacionOff.addEventListener('click',function()
    {
        $.destroy();
        Alloy.createController("").getView().open();
    });
 
}catch(e){
    alert("ERRORRO: "+e);
}
thank you very much

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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