当前位置: 首页>>代码示例>>Java>>正文


Java ArrayInstance.getTotalRetainedSize方法代码示例

本文整理汇总了Java中com.squareup.haha.perflib.ArrayInstance.getTotalRetainedSize方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayInstance.getTotalRetainedSize方法的具体用法?Java ArrayInstance.getTotalRetainedSize怎么用?Java ArrayInstance.getTotalRetainedSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.haha.perflib.ArrayInstance的用法示例。


在下文中一共展示了ArrayInstance.getTotalRetainedSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeIgnoredBitmapRetainedSize

import com.squareup.haha.perflib.ArrayInstance; //导入方法依赖的package包/类
/**
 * Bitmaps and bitmap byte arrays are sometimes held by native gc roots, so they aren't included
 * in the retained size because their root dominator is a native gc root.
 * To fix this, we check if the leaking instance is a dominator for each bitmap instance and then
 * add the bitmap size.
 *
 * From experience, we've found that bitmap created in code (Bitmap.createBitmap()) are correctly
 * accounted for, however bitmaps set in layouts are not.
 */
private int computeIgnoredBitmapRetainedSize(Snapshot snapshot, Instance leakingInstance) {
  int bitmapRetainedSize = 0;
  ClassObj bitmapClass = snapshot.findClass("android.graphics.Bitmap");

  for (Instance bitmapInstance : bitmapClass.getInstancesList()) {
    if (isIgnoredDominator(leakingInstance, bitmapInstance)) {
      ArrayInstance mBufferInstance = fieldValue(classInstanceValues(bitmapInstance), "mBuffer");
      // Native bitmaps have mBuffer set to null. We sadly can't account for them.
      if (mBufferInstance == null) {
        continue;
      }
      long bufferSize = mBufferInstance.getTotalRetainedSize();
      long bitmapSize = bitmapInstance.getTotalRetainedSize();
      // Sometimes the size of the buffer isn't accounted for in the bitmap retained size. Since
      // the buffer is large, it's easy to detect by checking for bitmap size < buffer size.
      if (bitmapSize < bufferSize) {
        bitmapSize += bufferSize;
      }
      bitmapRetainedSize += bitmapSize;
    }
  }
  return bitmapRetainedSize;
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:33,代码来源:HeapAnalyzer.java

示例2: computeIgnoredBitmapRetainedSize

import com.squareup.haha.perflib.ArrayInstance; //导入方法依赖的package包/类
/**
 * Bitmaps and bitmap byte arrays are sometimes held by native gc roots, so they aren't included
 * in the retained size because their root dominator is a native gc root.
 * To fix this, we check if the leaking instance is a dominator for each bitmap instance and then
 * add the bitmap size.
 *
 * From experience, we've found that bitmap created in code (Bitmap.createBitmap()) are correctly
 * accounted for, however bitmaps set in layouts are not.
 */
private long computeIgnoredBitmapRetainedSize(Snapshot snapshot, Instance leakingInstance) {
  long bitmapRetainedSize = 0;
  ClassObj bitmapClass = snapshot.findClass("android.graphics.Bitmap");

  for (Instance bitmapInstance : bitmapClass.getInstancesList()) {
    if (isIgnoredDominator(leakingInstance, bitmapInstance)) {
      ArrayInstance mBufferInstance = fieldValue(classInstanceValues(bitmapInstance), "mBuffer");
      // Native bitmaps have mBuffer set to null. We sadly can't account for them.
      if (mBufferInstance == null) {
        continue;
      }
      long bufferSize = mBufferInstance.getTotalRetainedSize();
      long bitmapSize = bitmapInstance.getTotalRetainedSize();
      // Sometimes the size of the buffer isn't accounted for in the bitmap retained size. Since
      // the buffer is large, it's easy to detect by checking for bitmap size < buffer size.
      if (bitmapSize < bufferSize) {
        bitmapSize += bufferSize;
      }
      bitmapRetainedSize += bitmapSize;
    }
  }
  return bitmapRetainedSize;
}
 
开发者ID:square,项目名称:leakcanary,代码行数:33,代码来源:HeapAnalyzer.java


注:本文中的com.squareup.haha.perflib.ArrayInstance.getTotalRetainedSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。