Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-8631

Memory leak in navigator.geolocation.getCurrentPosition on iOS

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • 4.0.0
    • None
    • 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

    Description

      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 and reports the correct position.

      Attachments

        Activity

          People

            Unassigned Unassigned
            rwillett Robert Willett
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: