谷歌地图api中的内存泄漏

时间:2013-06-15 14:10:00

标签: android google-maps google-maps-android-api-2

我的活动只是在地图(谷歌android v2 api)和图像之间切换。我使用MapFragment。 出于某种原因,即使我尝试做map.clear(),它仍然保留在内存中。 您可以看到,每次显示地图时,我在内存映射中都有一个新的maps.z.a实例。 怎么清楚这些?我也试过手动运行System.gc()。

Class Name                                                   | Shallow Heap | Retained Heap | Percentage
---------------------------------------------------------------------------------------------------------
                                                             |              |               |           
class android.content.res.Resources @ 0x41267910 System Class|           40 |     8,526,400 |     39.29%
android.graphics.Bitmap @ 0x421b0620                         |           48 |     5,760,064 |     26.54%
android.graphics.Bitmap @ 0x415a33e0                         |           48 |     1,127,600 |      5.20%
maps.as.aw @ 0x434a6750                                      |          160 |       278,072 |      1.28%
maps.p.c @ 0x421b4110                                        |           32 |       211,040 |      0.97%
maps.z.a @ 0x4218f698                                        |          152 |       205,864 |      0.95%
maps.z.a @ 0x421f69a8                                        |          152 |       205,256 |      0.95%
maps.z.a @ 0x4222f5c8                                        |          152 |       205,256 |      0.95%
maps.z.a @ 0x4366fb20                                        |          152 |       205,256 |      0.95%
android.graphics.Bitmap @ 0x41feb6e0                         |           48 |       160,064 |      0.74%
java.util.zip.ZipFile @ 0x42155b40                           |           32 |       139,704 |      0.64%
maps.as.q @ 0x41f35e30                                       |           80 |       131,536 |      0.61%
maps.as.q @ 0x421dcad8                                       |           80 |       131,536 |      0.61%
maps.as.q @ 0x434e7d90                                       |           80 |       131,536 |      0.61%
maps.as.q @ 0x435ccc40                                       |           80 |       131,536 |      0.61%
maps.as.aw @ 0x420c5e90                                      |          160 |       127,944 |      0.59%
class android.text.Html$HtmlParser @ 0x41e18f98 System Class |            8 |       126,632 |      0.58%
maps.as.aw @ 0x435bc4e0                                      |          160 |       111,624 |      0.51%
android.graphics.Bitmap @ 0x415e6708                         |           48 |       100,304 |      0.46%
class libcore.icu.TimeZones @ 0x4123d1e8 System Class        |           40 |        90,080 |      0.42%
---------------------------------------------------------------------------------------------------------

代码段:

添加到视图

frag = MapFragment.newInstance();
// Add the MapFragment to the view
FragmentTransaction ft = ((Activity) context).getFragmentManager().beginTransaction();
ft.add(this.getId(), frag).commit();

从视图中删除

FragmentTransaction ft = ((Activity) context).getFragmentManager().beginTransaction();
ft.remove(frag).commit();

0 个答案:

没有答案