Select to view content in your preferred language

Maps-App sample question

1050
3
09-04-2013 06:49 PM
ThomasBinu
Deactivated User
In the latest Maps-App sample, mMapView object is declared as a static variable. But I havent seen this in their Arcgis android samples. Is it a good practice to declare MapView objects as static?
0 Kudos
3 Replies
JuliusBagdonas
Emerging Contributor
MapView extends ViewGroup, so it must be an awful idea since it will leak the Context... at least thats what I think.

http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks.html
0 Kudos
NathanMellor
Regular Contributor
Definitely a bad idea.

Google had a context leak in their Google Analytics sample code. Took a week to track down.
0 Kudos
DanO_Neill
Deactivated User
Although I have not seen memory issues in the app, I have made the change to the maps-app by removing the static qualifier as it is not the recommended pattern for MapView.
0 Kudos