内存在View的一个实例上泄漏

时间:2013-10-29 06:38:47

标签: java android memory-management memory-leaks out-of-memory

我在ColumnListView上遇到了内存泄漏,我将在漏洞嫌疑人下面显示。它占用分配内存的2,720,840(18.65%)字节。

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {


    gView = inflater.inflate(R.layout.ac_image_grid, container, false);


    multi = new WeakReference<ColumnListView> ((ColumnListView) (finalView.findViewById(R.id.list)));

One instance of "com.lib.ColumnListView" loaded by "dalvik.system.PathClassLoader @ 0x4123aa30" occupies 2,720,840 (18.65%) bytes. The memory is accumulated in one instance of "byte[]" loaded by "<system class loader>".

Keywords
dalvik.system.PathClassLoader @ 0x4123aa30
com.lib.ColumnListView
byte[]

XML

<?xml version="1.0" encoding="utf-8"?>
    <com.lib.ColumnListView 
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:pla="http://schemas.android.com/apk/res-auto"
        android:id="@+id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        pla:plaColumnNumber="2"
        pla:plaLandscapeColumnNumber="3"
        >
    </comlib.ColumnListView>

1 个答案:

答案 0 :(得分:1)

这只是一个猜测,但你的演员语法对我来说很奇怪,这也可能导致问题。相反,尝试:

multi = new WeakReference<ColumnListView> ((ColumnListView)finalView.findViewById(R.id.list));