Memory leak for Android Google Maps API v2

前端 未结 2 1667
-上瘾入骨i
-上瘾入骨i 2021-01-16 10:20

I\'m struggling with a memory leak issue at Google Maps Android API v2. The heap usage increases by about 85KB every time my view becomes visible again after:

2条回答
  •  爱一瞬间的悲伤
    2021-01-16 10:56

    I tried to use System.gc() and map.clear() before the map is initialized.

      @Override
    public void onActivityCreated (Bundle savedInstanceState){
        super.onActivityCreated(savedInstanceState);
    
        if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity()) == ConnectionResult.SUCCESS) {
            System.gc();
    getMap().clear();
    setupmap();
    
    
        }
    }
     @Override
    public void onLowMemory() {
      super.onLowMemory();
    System.gc();
    }
    

提交回复
热议问题