cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Willett (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CB-8631) Memory leak in navigator.geolocation.getCurrentPosition
Date Sat, 07 Mar 2015 10:17:38 GMT
Robert Willett created CB-8631:
----------------------------------

             Summary: Memory leak in navigator.geolocation.getCurrentPosition
                 Key: CB-8631
                 URL: https://issues.apache.org/jira/browse/CB-8631
             Project: Apache Cordova
          Issue Type: Bug
          Components: Plugin Geolocation
    Affects Versions: 4.0.0
         Environment: Mac - Mavericks 10.9.5, Version 6.1.1 (6A2008a), Cordova 4.1.2. Also
same behaviour on Mac Yosemite 10.10.2 , iOS Simulator 8.1, 7.1 and iOS phone 8.1, cordova
version reported as 4.1.2
            Reporter: Robert Willett


Calling navigator.geolocation.getCurrentPosition appears to leak memory, 

A simple test case with all steps:

1. cordova create geolocationtest com.example.geolocation GeoLocation 

2. cordova plugins add org.apache.cordova.console

3. cordova plugin add org.apache.cordova.geolocation

4. cordova platform add iOS

5. Replace the www/js/index.js with the below below. This is basically the starter code and
only two functions have been added, onSuccess and onFailure along with a timer call to navigator.geolocation.getCurrentPosition()

function onSuccess(position) {
    console.log("Success...");
}

function onFailure(error) {
    console.log("Failed...");
}

var app = {
    // Application Constructor                                                           
                                                                                         
                      
    initialize: function() {
        this.bindEvents();
    },

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

    onDeviceReady: function() {
        app.receivedEvent('deviceready');

        setInterval(function () {
                navigator.geolocation.getCurrentPosition(onSuccess , onFailure);
            } , 1000);
    },

    receivedEvent: function(id) {
        var parentElement = document.getElementById(id);
        var listeningElement = parentElement.querySelector('.listening');
        var receivedElement = parentElement.querySelector('.received');

        listeningElement.setAttribute('style', 'display:none;');
        receivedElement.setAttribute('style', 'display:block;');

        console.log('Received Event: ' + id);
    }
};

app.initialize();

6. cordova build ios

7. Run the code in Xcode. The memory footprint keeps climbing as memory from the getCurrentPosition
call does not appear to be released. 

8. Commenting out the console.log entries stills shows the memory footprint climbing around
200K per call to navigator.geolocation.getCurrentPosition().

The navigator.geolocation.getCurrentPosition call appears to work correctly. 



--
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