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

Sergey Grebnov commented on CB-8631:
------------------------------------

Reviewed code and run sample code w/ memory profiler on iPhone 5 OSX 9.2(I only 
removed console.log calls) - everything looks correct. Please note that every 
getCurrentPosition call creates new CLLocationManager instance, but I can also 
confirm that it is correctly stopped after location is retrieved (or request is 
failed)

!screenshot-memory-usage(no-repro).png!

> Memory leak in navigator.geolocation.getCurrentPosition on iOS
> --------------------------------------------------------------
>
>                 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
>            Reporter: Robert Willett
>              Labels: geolocation, ios, memory-leak, triaged
>         Attachments: screenshot-memory-usage(no-repro).png
>
>
> 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.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to