Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7467] iOS: Map Annotation Memory Leak

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2015-01-22T20:06:17.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sSprint 2012-03, Release 2.0.0, Release 1.8.2
ComponentsiOS
Labelsmodule_map, qe-testadded
ReporterMauro Parra-Miranda
AssigneeJon Alter
Created2012-01-30T10:14:16.000+0000
Updated2015-01-22T20:06:17.000+0000

Description

PROBLEM DESCRIPTION

User added and removed annotations from the map, it was releasing the TiMapAnnotationProxy but not the TiMapPinAnnotationView. It kept them "Living" and continued to add to their live bytes instead of moving the old ones into "Transitory".

ACTUAL BEHAVIOR

TiMapPinAnnotationView is not being released.

EXPECTED BEHAVIOR

TiMapPinAnnotationView should be released when not needed.

TEST CASE

var win = Ti.UI.createWindow({
    title:'Map'
}),
map = Ti.Map.createView({
    region:{
        latitude:36,
        latitudeDelta:5,
        longitude:-93,
        longitudeDelta:5
    },
    toggled:false,
    userLocation:false
}),
toggleAnnos = function(e){
    var lat = 31,
        lng = (e.source.toggled ? -98 : -89),
        annos = [];
    for(i=0;i<10;i++){
        annos.push({latitude:lat,longitude:lng});   
        lat++;
        if(e.source.toggled){
            lng++;
        }else{
            lng--;
        }
    }
    e.source.removeAllAnnotations();
    e.source.addAnnotations(annos);
    e.source.toggled = !e.source.toggled;
};
win.add(map);
win.open();
map.addEventListener('regionChanged',toggleAnnos);

COMMUNITY DISCUSSION

http://developer.appcelerator.com/question/131291/map-annotation-memory-leak

Attachments

FileDateSize
AnnotationsReleased.png2015-01-22T20:00:46.000+000098355
Screen Shot 2014-03-28 at 2.44.44 PM.png2014-03-28T21:48:20.000+0000149316

Comments

  1. Michael Pettiford 2012-02-07

    Closing issue Tested with Ti Studio build 1.0.8.201201262211 Ti Mob SDK 1.9.0.v20120207124634 OSX Lion 10.7.2 Expected behavior is shown of no memory leaks when changing map annotations
  2. Olga Romero 2014-03-28

    Reopened, please refer to the screenshot Mac osx 10.9.2 Mavericks Appcelerator Studio, build: 3.2.3.201403271839 Titanium SDK, build:3.2.3.v20140327115429 Node.JS Version: v0.10.13 NPM Version: 1.3.2 /usr/local/lib ├── acs@1.0.14 ├── alloy@1.3.1 ├── node-appc@0.2.0 ├── npm@1.3.2 ├── titanium@3.2.3-alpha2 └── titanium-code-processor@1.1.1-alpha Devices: iPad air iOS 7.1 iPhone 5S iOS 7.1
  3. Satyam Sekhri 2014-12-05

    The issue still exists. The TiMapPinAnnotationView object is not released. Tested on: SDK: 3.5.0.v20141203160911 Studio: 3.4.1.201410281743 CLI: 3.4.1 Alloy: 1.5.1 Ti.Map: 2.2.0 Xcode: 6.1 Device: iPad mini 3 (v8.1)
  4. Jon Alter 2015-01-22

    TiMapPinAnnotationViews are getting released as they should. In the attached screen shot !AnnotationsReleased.png! See the number of persistent annotations is 10 and the number of transient is 510. This means that 520 annotations were created and 510 have been released as expected. The other 10 annotations are still alive because they are currently on the map.

    To test

    1. Include the latest iOS Map module (2.2.0 at the time of writing) 2. Use the example code below 3. Build the app 4. In the build/iphone/ folder, open the Xcode project with Xcode. 5. In Xcode click *Product*>*Profile* 6. When given the option of what type of profiling to do, select "Memory Leaks" 7. In Instruments click the "Record" button 8. The app will launch on the *simulator* 9. In the filter type "TiMap" 10. In the app move the map a little bit 11. Notice the "# Persistent" and "# Transient" 12. After moving the map a few times, you may see that the number of persistent Annotations is more than 10 13. In the simulator menu, click *Hardware*>*Simulate Memory Warning* 14. Notice the number of Annotations drop down to 10 (These are the 10 currently displayed on the map) 15. You will also see the number of Persistent Annotations drop after you move the map a few more times and create a little memory pressure.
       var Map = require('ti.map');
       
       var win = Ti.UI.createWindow({
           title:'Map'
       }),
       // map = Ti.Map.createView({
       map = Map.createView({
           region:{
               latitude:36,
               latitudeDelta:5,
               longitude:-93,
               longitudeDelta:5
           },
           toggled:false,
           userLocation:false
       }),
       toggleAnnos = function(e){
           var lat = 31,
               lng = (e.source.toggled ? -98 : -89),
               annos = [];
           for(i=0;i<10;i++){
               annos.push({latitude:lat,longitude:lng});   
               lat++;
               if(e.source.toggled){
                   lng++;
               }else{
                   lng--;
               }
           }
           e.source.removeAllAnnotations();
           e.source.addAnnotations(annos);
           e.source.toggled = !e.source.toggled;
       };
       win.add(map);
       win.open();
       map.addEventListener('regionChanged',toggleAnnos);
       

JSON Source