package com.njnu.kai.practice.memory;


import android.view.View;
import android.widget.ImageView;

import com.njnu.kai.support.BaseTestListFragment;
import com.njnu.kai.support.TestFunction;

/**
 * @author hongkai.qian
 * @version 1.0.0
 * @since 17/3/17
 */
public class MemoryLeakFragment extends BaseTestListFragment {

    @TestFunction("创建1000个ImageView")
    public void onTest01() {
        for (int i = 0; i < 1000; i++) {
            View view = new ImageView(getActivity());
        }
    }
}

@@ -33,16 +33,215 @@
 mory;%0A%0A%0A
+import android.content.BroadcastReceiver;%0Aimport android.content.Context;%0Aimport android.content.Intent;%0Aimport android.content.IntentFilter;%0Aimport android.support.v4.content.LocalBroadcastManager;%0A
 import a
@@ -694,11 +694,867 @@
  %7D%0A    %7D
+%0A%0A    @TestFunction(%22%E5%88%9B%E5%BB%BA1000%E4%B8%AAImageView,%E4%B8%BB%E5%8A%A8gc%22)%0A    public void onTest02() %7B%0A        for (int i = 0; i %3C 1000; i++) %7B%0A            View view = new ImageView(getActivity());%0A        %7D%0A        System.gc();// 4.x%E5%8F%AF%E4%BB%A5 art%E4%B8%8D%E4%B8%80%E5%AE%9A 5.x%E4%B8%8D%E4%B8%80%E5%AE%9A %E4%BB%85%E6%A0%87%E8%AE%B0%0A        System.runFinalization();%0A//        Runtime.getRuntime().gc();%0A    %7D%0A%0A    @TestFunction(%22register Receiver but not unregister%22)%0A    public void onTest03() %7B%0A        LocalBroadcastManager.getInstance(getContext()).registerReceiver(new TestBroadcastReceiver(), new IntentFilter(%22xxxxAction%22));%0A        //%E5%A6%82%E6%9E%9CTestBroadcastReceiver%E6%98%AF%E9%9D%99%E6%80%81%E7%B1%BB,%E4%B8%8D%E4%BC%9A%E6%B3%84%E9%9C%B2MemoryLeakFragment%E6%9C%AC%E8%BA%AB,receiveRecord%E6%8C%81%E6%9C%89TestBroadcastReceiver%0A        //%E4%BD%86%E5%A6%82%E6%9E%9C%E4%B8%8D%E6%98%AF%E9%9D%99%E6%80%81%E7%B1%BB, %E5%88%99%E4%B8%8D%E4%BC%9A%E6%B3%84%E9%9C%B2MemoryLeakFragment%E4%B9%9F%E4%BC%9A%E8%A2%ABreceiver%E6%8C%81%E6%9C%89%0A    %7D%0A%0A    private class TestBroadcastReceiver extends BroadcastReceiver %7B%0A        @Override%0A        public void onReceive(Context context, Intent intent) %7B%0A%0A        %7D%0A    %7D
 %0A%7D%0A

test memory leak use reveiver register