Google Maps API causing memory leak?


I just started using the Eclipse Memory Analyzer to try to solve the memory leak problem in my activity, which extends MapActivity, but I'm not sure if I understand its output correctly. To analyze the leak, I started work and turned the screen several times, and then I took a bunch of heaps and opened it. The first thing I did was open the Histogram Image and see my activity (called ChangeLocationActivity). It really looks like a memory leak, since there are three instances of the same action. So I got a list of objects with incoming links, then I got the "Path to GC Roots", excluding weak links for all three instances. This is the path of the first instance, this for the second instance (this custom MyLocationOverlay is a really simple class designed to work around the error on some Motorola devices and has nothing special except to catch the exception in drawMyLocation ()) and finally this is the one shown in the third instance, which looks like the one shown.

As I said, I'm not sure if I understood these results correctly (Eclipse Memory Analyzer is really powerful, but rather complicated), but from what I can say, it seems that the reason for the memory leak is something related to Google Maps library. Can someone tell me if I am correct, or if I just do not understand these results?

+4
source share
1 answer

Select all the actions and use "Combine the shortest paths to the roots of the GC." Submit the result here. Your second activity seems to be alive because you registered an EventListener.

"Combine the Shortest Paths to GC Roots" is one of the most important commands in MAT. It displays all the templates for objects in the roots, but combines them and, therefore, allows you to analyze which objects are still alive, because they have the same strokes. From your screenshot (please expand the three subtrees), it seems that your 3 activities have three root objects. For leaks, it is typical to distribute some common objects along their combined root paths. Typically, from what I saw in your case, you have several reasons for the leak, because each action is performed by a different root object. I would recommend trying to get as many actions as possible by repeating the test.

Regards, Marcus

0
source

Source: https://habr.com/ru/post/1385933/


All Articles