b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

leak suspect_MemoryAnalyzer.exe_celebrity leak(2)

电脑杂谈  发布时间:2017-05-22 05:04:25  来源:网络整理

下一步,点击Details

再点击下面的Class Name,查看Inspector【显示了当前显示类或对象的详细信息】

通过Inspector能知道使用了javax.imageio.ImageReader接口,我们处理图片的任务都在ImageResize.java类中,然后对这块代码进行分析排查。

最初怀疑自动截图这块的影响,单独对自动截图功能做批量测试,循环截图100,1000次dump内存看基本都没有太大变化。

代码排查:

try{

//ImageReader声称能够解码指定格式

Iterator<ImageReader> it = ImageIO.getImageReadersByFormatName(ext);

ImageReader reader = it.next();

// 输入源中的图像将只按顺序读取

reader.setInput(iis, true);

int srcWidth = reader.getWidth(0); // 源图宽度

int srcHeight = reader.getHeight(0); // 源图高度

if (srcWidth >= destWidth && srcHeight >= destHeight) {

// 处理图片...

reader.dispose();

}

}catch (Exception e) {

logger.error("Cut image failed, src_image_file:{}, error:{}, ", srcImageFile, e.getMessage(), e);

} finally {

// ...

}

从ImageReader入手查看代码,发现调用了dispose方法,但是只在try中做了调用,finally中并没有调用dispose方法。怀疑如果if条件不成立或者有异常发生,则不会调用dispose方法。

查看下dispose方法的含义,如果不再使用这个ImageReader对象时,必须调用这个方法释放资源;否则,可能导致资源(内存)无限的被占用。

/**

* Allows any resources held by this object to be released. The

* result of calling any other method (other than

* <code>finalize</code>) subsequent to a call to this method

* is undefined.

*

* <p>It is important for applications to call this method when they

* know they will no longer be using this <code>ImageReader</code>.

* Otherwise, the reader may continue to hold on to resources

* indefinitely.

*

* <p>The default implementation of this method in the superclass does

* nothing. Subclass implementations should ensure that all resources,


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-48515-2.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 张朋林
      张朋林

      上午10点半飞过广场后各自回场

    • 韦纯光
      韦纯光

      _)

    • 吴俊伯
      吴俊伯

      好机智幽默得体不抖包袱真的很棒

    热点图片
    拼命载入中...