cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andreas Waal (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CB-7660) Cordova iOS File-Transfer download memory leaks
Date Thu, 18 Dec 2014 13:37:13 GMT

    [ https://issues.apache.org/jira/browse/CB-7660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14251649#comment-14251649
] 

Andreas Waal edited comment on CB-7660 at 12/18/14 1:36 PM:
------------------------------------------------------------

Hi, 
I am also experiencing this issue. Memory building up and eventually crashing the app. Please
see attached screenshots.  After a day of debugging this is what I found. 

* This issue occures when downloading large amounts( 10k ++)  of small files.  
* When downloading large amounts of large files, it releases memory correctly. 

What I tried without any sucess:
* Adding delay after n-number downloads
* Adding delay after each download

This can be reproduces with the following Cordova program.

{code}


var DownloadFile = function(){
    return {
        downloadFile :function(file,done){
            console.log(JSON.stringify(file));
            function win(entry)
            {
                console.log("Downloaded : " + file.name + " ok");
                done();
            }

            function fail(error)
            {
                console.log("ERROR!");
                console.log(error.code);
                done();
            }


            var uri = encodeURI(file.url);
            window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
                fileSystem.root.getFile(file.name, {create: true, exclusive: false}, function(fileEntry)
{
                    var localPath = fileEntry.toURL();
                    var ft = new FileTransfer();
                    ft.download(uri,localPath,win,fail,false);

                },function(error){console.log("errore 1: " + error.code);});
            },function(error){console.log("errore 2: " + error.code);});
        }
    }
};


var getFiles = function(){
    var smallFile = 'https://upload.wikimedia.org/wikipedia/en/4/4d/Sample_sawtooth.jpg';
    var largeFile = "http://upload.wikimedia.org/wikipedia/commons/5/5b/Ultraviolet_image_of_the_Cygnus_Loop_Nebula_crop.jpg";

    var files = [];
    for(var i = 0; i < 50000; i++){
        files.push({name : i + '.jpg', url : largeFile});
    }
    return files;
};


function startDownload(){
    var downloadFileNative = new DownloadFile();
    var files = getFiles();
    var downloadNext = function(){
        document.getElementById("status").innerText = 'Files left :' + files.length;
        if(files.length > 0){
            downloadFileNative.downloadFile(files.splice(0,1)[0],downloadNext);
        }
    };
    downloadFileNative.downloadFile(files.splice(0,1)[0],downloadNext);
}

var app = {
    initialize: function() {
        this.bindEvents();

    },
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
    onDeviceReady: function() {
        startDownload();
    }
};

app.initialize();


{code}




 






was (Author: andwaal):
Hi, 
I am also experiencing this issue. Please see attached screenshots. After a day of debugging
this is what I found. 

* This issue occures when downloading large amounts( 10k ++)  of small files.  
* When downloading large amounts of large files, it releases memory correctly. 

What I tried without any sucess:
* Adding delay after n-number downloads
* Adding delay after each download

This can be reproduces with the following Cordova program.

{code}


var DownloadFile = function(){
    return {
        downloadFile :function(file,done){
            console.log(JSON.stringify(file));
            function win(entry)
            {
                console.log("Downloaded : " + file.name + " ok");
                done();
            }

            function fail(error)
            {
                console.log("ERROR!");
                console.log(error.code);
                done();
            }


            var uri = encodeURI(file.url);
            window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
                fileSystem.root.getFile(file.name, {create: true, exclusive: false}, function(fileEntry)
{
                    var localPath = fileEntry.toURL();
                    var ft = new FileTransfer();
                    ft.download(uri,localPath,win,fail,false);

                },function(error){console.log("errore 1: " + error.code);});
            },function(error){console.log("errore 2: " + error.code);});
        }
    }
};


var getFiles = function(){
    var smallFile = 'https://upload.wikimedia.org/wikipedia/en/4/4d/Sample_sawtooth.jpg';
    var largeFile = "http://upload.wikimedia.org/wikipedia/commons/5/5b/Ultraviolet_image_of_the_Cygnus_Loop_Nebula_crop.jpg";

    var files = [];
    for(var i = 0; i < 50000; i++){
        files.push({name : i + '.jpg', url : largeFile});
    }
    return files;
};


function startDownload(){
    var downloadFileNative = new DownloadFile();
    var files = getFiles();
    var downloadNext = function(){
        document.getElementById("status").innerText = 'Files left :' + files.length;
        if(files.length > 0){
            downloadFileNative.downloadFile(files.splice(0,1)[0],downloadNext);
        }
    };
    downloadFileNative.downloadFile(files.splice(0,1)[0],downloadNext);
}

var app = {
    initialize: function() {
        this.bindEvents();

    },
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
    onDeviceReady: function() {
        startDownload();
    }
};

app.initialize();


{code}




 





> Cordova iOS File-Transfer download memory leaks
> -----------------------------------------------
>
>                 Key: CB-7660
>                 URL: https://issues.apache.org/jira/browse/CB-7660
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File Transfer
>    Affects Versions: 3.5.0
>         Environment: iOS 7.0.3 on iPad2 - Cordova 3.5
>            Reporter: Jordi Valls Carbonell
>            Assignee: Shazron Abdullah
>         Attachments: LargeFiles.png, SmallFiles.png
>
>
> File-Transfer memory leaks downloading files, no memory is released for each file downloaded,
finally i got "Memory Warning".
> To test add a button and call "testDownload" function every time console confirmation
message is displayed ("DOWNLOADED OK")
> {code}
> function win(entry)
> {
>     console.log("DOWNLOADED OK");
> }
> function fail(error)
> {
>     console.log("ERROR!");
>     console.log(error.code);
> }
> function testDownload
> {
> var url = "http://upload.wikimedia.org/wikipedia/commons/5/5b/Ultraviolet_image_of_the_Cygnus_Loop_Nebula_crop.jpg";
> var filename = "filename.jpg";
> var uri = encodeURI(url);
> window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
>        fileSystem.root.getFile(filename, {create: true, exclusive: false}, function(fileEntry)
{
>            var localPath = fileEntry.toURL();
>            var ft = new FileTransfer();
>            ft.download(uri,localPath,win,fail,false);
>        },function(error){console.log("errore 1: " + error.code);});
>     },function(error){console.log("errore 2: " + error.code);});
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message