Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak class DelegatingOnCameraChangeListener i #54

Open
maxime-kouemo opened this issue Sep 13, 2017 · 4 comments
Open

Memory leak class DelegatingOnCameraChangeListener i #54

maxime-kouemo opened this issue Sep 13, 2017 · 4 comments

Comments

@maxime-kouemo
Copy link

maxime-kouemo commented Sep 13, 2017

First of all thank you for this library. I have been able to flawlessly add more than 5000 markers on the map. Yet, when I rotate the device, I have a memory leak. I changed the code to use only the googlemaps one without the elements of AME and I didn't have any memory leak while rotating the screen (yet I can't add that more markers with such fluidity).
Here is the Java Heap Dump capture:
tvjzlzv1pp5x_android_studio_trace

When I make a right click and jump to source it brings me here:

private class DelegatingOnCameraChangeListener implements com.google.android.gms.maps.GoogleMap.OnCameraChangeListener {

        @Override
        public void onCameraChange(CameraPosition cameraPosition) {
            markerManager.onCameraChange(cameraPosition);
            if (onCameraChangeListener != null) {
                onCameraChangeListener.onCameraChange(cameraPosition);
            }
        }
    }

Keep in mind that in the destroy view of the mapview I use this (to make sure every thing is cleaned) :

if(googleMap != null) {
            googleMap.setOnMapClickListener(null);
            googleMap.setOnMarkerClickListener(null);
            googleMap.setInfoWindowAdapter(null);
            googleMap.setOnCameraChangeListener(null); // <--
            googleMap.setOnGroundOverlayClickListener(null);
            googleMap.setOnCameraMoveCanceledListener(null);
            googleMap.setOnCameraMoveListener(null);
            googleMap.setOnCameraMoveStartedListener(null);
            googleMap.setOnCircleClickListener(null);
            googleMap.setOnMyLocationChangeListener(null);
            googleMap.setOnMapLongClickListener(null);
            googleMap.setOnInfoWindowClickListener(null);
            googleMap.setOnInfoWindowCloseListener(null);
            googleMap.setOnInfoWindowLongClickListener(null);
            googleMap.setOnPoiClickListener(null);
            googleMap.setOnPolygonClickListener(null);
            googleMap.setOnPolylineClickListener(null);
            googleMap.setClustering(null);
        }

Here is the version that I currently use:

compile 'com.google.android.gms:play-services-maps:9.8.0'
compile 'com.androidmapsextensions:android-maps-extensions:2.4.0'

1- Is there anyway to fix that memory leak from the library side?
2- For all your handlers, can you use this, that uses weak references for its handlers to avoid any memory leak?

@mg6maciej
Copy link
Owner

Could you prepare a SSCCE, so I can look into this issue? A pull request with an Activity or Fragment that shows it would be perfect. You may look into old ones like this as starting point.

@maxime-kouemo
Copy link
Author

I wrote the project at work today, and you will be able to switch to google maps' map view to see what I am talking about. I have to wait until monday for my admin to check it before I can do the pull request (it is a compagny related work). Sorry for the incoming delay.

@maxime-kouemo
Copy link
Author

maxime-kouemo commented Sep 21, 2017

Hi, I have just added a .zip file (here) of the project. Sorry for such a huge file, be assure that there is no security issue or compromising file in the .zip . It is the easiest way for me at this time of writing.

@maxime-kouemo
Copy link
Author

Hi mg6maciej. Did you have the time to look it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants