matrix icon indicating copy to clipboard operation
matrix copied to clipboard

IOCanary type 4适应所有线程,type 2、3(小buffer、重复打开小文件)这两类为何只检测主线程的,有何考虑么?

Open hfutgl opened this issue 7 years ago • 3 comments

这个函数每秒调用一次,byte数组是16字节,然后在listener中一直没有提示该类问题

把finally中代码删除,再次测试listener中会提示type 4,泄露类问题

public void testFileInputStream3() { // abcdefgcde
    FileInputStream fis = null;
    try {
        File file = new File("hello.txt");
        fis = new FileInputStream(file);

        byte[] b = new byte[16];// 读取到的数据要写入的数组。

        int len;// 每次读入到byte中的字节的长度
        while ((len = fis.read(b)) != -1) {
            String str = new String(b, 0, len);
            System.out.print(str);
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (fis != null) {
            try {
                fis.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }

    }
}

hfutgl avatar Jan 31 '19 13:01 hfutgl

小buffer读写 这类问题的检测也限制在主线程中?

hfutgl avatar Jan 31 '19 13:01 hfutgl

2.type,耗时这边的类型有两种 a. MAIN_THREAD_IO=1, 在主线程IO超过200ms b. BUFFER_TOO_SMALL=2, 重复读取同一个文件,同一个堆栈超过3次 c. REPEAT_IO=3, 读写文件的buffer过小,即小于4k d. CLOSE_LEAK=4, 文件泄漏

b/c的描述是不是反了

hfutgl avatar Feb 01 '19 02:02 hfutgl

这里是一个改进点。见#69

lolobug avatar Feb 14 '19 03:02 lolobug