热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Android性能优化(23)*性能工具之「HeapViewer,MemoryMonitor,AllocationTracker」MemoryProfilers

InthisdocumentMemoryMonitorHeapViewerAllocationTrackerYoushouldalsoreadMemoryMonitorWalkth

  In this document

  • Memory Monitor
  • Heap Viewer
  • Allocation Tracker

  You should also read

  • Memory Monitor Walkthrough
  • Heap Viewer Walkthrough
  • Allocation Tracker Walkthrough

1.简介

  Heap Viewer, Memory Monitor, and Allocation Tracker are complementary tools that visualize the memory your app uses.

  1. Use the Memory Monitor Tool to find out whether undesirable garbage collection (GC) event patterns might be causing your performance problems.
    Memory Monitor Tool 可分析出哪里有内存问题。
  2. Run Heap Viewer to identify object types that get or stay allocated unexpectedely or unecessarily.
    Heap Viewer 标识出哪个对象是不必要的分配。
  3. Use Allocation Tracker to identify where in your code the problem might be.
    Allocation Tracker 定位问题代码

2.Memory Monitor

  • Shows available and used memory as they both change over time for your app in a graph, with dips indicating Garbage Collection (GC) events.
  • Provides a quick way to test whether app slowness might be related to excessive GC events.
    可测试是否由于过多的GC导致应用变慢。
  • Provides a quick way to see whether app crashes might be related to running out of memory.
    检查是否由于内存不足导致应用崩溃。
  • Runs live on your application and updates about once a second.
  • Helps quickly identify the potential of memory leaks.
    标识潜在的内存泄漏。
  • Helps identify GC patterns for your application and determine whether they are healthy and what you expect.
    标识GC运行是否健康。
  • Is easy to use, and it is easy to interpret what you see.
  • However, Memory Monitor does not tell you which objects are the cause of your problems, or where in your code it might be.
    它的缺点是并不能指出是哪个对象有问题,哪句代码有问题。

    Android 性能优化(23)*性能工具之「Heap Viewer, Memory Monitor, Allocation Tracker」Memory Profilers

      Figure 1. Memory Monitor.

3.Heap Viewer

  • Shows snapshots of a number of objects allocated by type.
  • Samples data every time a garbage collection event occurs naturally or triggered by you.
    采集每次自动或手动GC的对象。
  • Helps identify which object types might be involved in memory leaks.
    标识出哪些对象可能与内存泄漏有关。
  • However, you have to look for changes over time yourself by tracking what's happening in the graph.
    Android 性能优化(23)*性能工具之「Heap Viewer, Memory Monitor, Allocation Tracker」Memory Profilers
          Figure 2. Heap Viewer.

4.Allocation Tracker 

  • Shows when and where your code allocates object types, their size, allocating thread, and stack traces.
    记录内存分配信息。
  • Helps recognize memory churn through recurring allocation/deallocation patterns.
    识别重复无效的内存分配。
  • Can be used in combination with Heap Viewer to track down memory leaks. For example, if you see a bitmap object resident on the heap, you can find its allocation location with Allocation Tracker.
    帮助Heap Viewer, Memory Monitor 分析内存泄漏。
  • However, it takes time and experience to learn to interpret the output from this tool.
     Android 性能优化(23)*性能工具之「Heap Viewer, Memory Monitor, Allocation Tracker」Memory Profilers
        Figure 3. Allocation Tracker.
 
 
 

推荐阅读
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 拥抱Android Design Support Library新变化(导航视图、悬浮ActionBar)
    转载请注明明桑AndroidAndroid5.0Loollipop作为Android最重要的版本之一,为我们带来了全新的界面风格和设计语言。看起来很受欢迎࿰ ... [详细]
  • 配置IPv4静态路由实现企业网内不同网段用户互访
    本文介绍了通过配置IPv4静态路由实现企业网内不同网段用户互访的方法。首先需要配置接口的链路层协议参数和IP地址,使相邻节点网络层可达。然后按照静态路由组网图的操作步骤,配置静态路由。这样任意两台主机之间都能够互通。 ... [详细]
  • 本文由编程笔记#小编整理,主要介绍了关于数论相关的知识,包括数论的算法和百度百科的链接。文章还介绍了欧几里得算法、辗转相除法、gcd、lcm和扩展欧几里得算法的使用方法。此外,文章还提到了数论在求解不定方程、模线性方程和乘法逆元方面的应用。摘要长度:184字。 ... [详细]
  • Android自定义控件绘图篇之Paint函数大汇总
    本文介绍了Android自定义控件绘图篇中的Paint函数大汇总,包括重置画笔、设置颜色、设置透明度、设置样式、设置宽度、设置抗锯齿等功能。通过学习这些函数,可以更好地掌握Paint的用法。 ... [详细]
  • VSCode快速查看函数定义和代码追踪方法详解
    本文详细介绍了在VSCode中快速查看函数定义和代码追踪的方法,包括跳转到定义位置的三种方式和返回跳转前的位置的快捷键。同时,还介绍了代码追踪插件的使用以及对符号跳转的不足之处。文章指出,直接跳转到定义和实现的位置对于程序员来说非常重要,但需要语言本身的支持。以TypeScript为例,按下F12即可跳转到函数的定义处。 ... [详细]
  • 本文介绍了lua语言中闭包的特性及其在模式匹配、日期处理、编译和模块化等方面的应用。lua中的闭包是严格遵循词法定界的第一类值,函数可以作为变量自由传递,也可以作为参数传递给其他函数。这些特性使得lua语言具有极大的灵活性,为程序开发带来了便利。 ... [详细]
  • 本文介绍了使用kotlin实现动画效果的方法,包括上下移动、放大缩小、旋转等功能。通过代码示例演示了如何使用ObjectAnimator和AnimatorSet来实现动画效果,并提供了实现抖动效果的代码。同时还介绍了如何使用translationY和translationX来实现上下和左右移动的效果。最后还提供了一个anim_small.xml文件的代码示例,可以用来实现放大缩小的效果。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • HDU 2372 El Dorado(DP)的最长上升子序列长度求解方法
    本文介绍了解决HDU 2372 El Dorado问题的一种动态规划方法,通过循环k的方式求解最长上升子序列的长度。具体实现过程包括初始化dp数组、读取数列、计算最长上升子序列长度等步骤。 ... [详细]
  • 本文介绍了C#中生成随机数的三种方法,并分析了其中存在的问题。首先介绍了使用Random类生成随机数的默认方法,但在高并发情况下可能会出现重复的情况。接着通过循环生成了一系列随机数,进一步突显了这个问题。文章指出,随机数生成在任何编程语言中都是必备的功能,但Random类生成的随机数并不可靠。最后,提出了需要寻找其他可靠的随机数生成方法的建议。 ... [详细]
  • 在开发app时,使用了butterknife后,在androidStudio打包apk时可能会遇到报错。为了解决这个问题,可以通过打开proguard-rules.pro文件进行代码混淆来解决。本文介绍了具体的混淆代码和方法。 ... [详细]
author-avatar
雅芳07866
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有