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
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
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
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)
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 thebuild/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.