Skip to content Skip to sidebar Skip to footer

Java.lang.outofmemoryerror With Google Maps Android Api V2

I wrote this program to overlap circles to show where I've been using the google maps android api v2. After about 2 hours I get the java.lang.OutOfMemoryError with the heap size be

Solution 1:

The location manager can take the parameters:

provider        the name of the provider with which to register
minTime         minimum timeintervalbetween location updates, in milliseconds
minDistance     minimum distance between location updates, in meters
listener        a LocationListener whose onLocationChanged(Location) method will be calledforeach location update

locationmanager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 200, 0, this);

Increasing the minimum time interval or distance between location updates will provide less circles on the map, thereby increasing the amount of time the program can be run before reaching the maximum heap size.

Solution 2:

You need to optimize it. Maybe you are drawing circles at the same coordinates. Each circle you draw is a memory allocation, so try to see if the onLocationChanged is called with the same locations some times.

Post a Comment for "Java.lang.outofmemoryerror With Google Maps Android Api V2"