gpt4 book ai didi

android - 如何找到创建字节数组的源

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:03:58 24 4
gpt4 key购买 nike

使用 DDMS 并创建 HPROF,我可以在我的应用程序中看到数据的“直方图” View ,并且注意到数量过多的非常大的“byte[]”对象。我怀疑这是我的代码中的错误或其他愚蠢行为的结果。但我不知道如何查看这些字节对象的名称或查看它们在我的源代码中创建的位置。这能做到吗?

最佳答案

看这里:DDMS Object Allocation Tracking它逐步指定如何跟踪对象分配并找到负责它的代码行。

Tracking memory allocation of objects

DDMS provides a feature to track objects that are being allocated to memory and to see which classes and threads are allocating the objects. This allows you to track, in real time, where objects are being allocated when you perform certain actions in your application. This information is valuable for assessing memory usage that can affect application performance.

To track memory allocation of objects:

  • In the Devices tab, select the process that you want to enable allocation tracking for.
  • In the Allocation Tracker tab, click the Start Tracking button to begin allocation tracking. At this point, anything you do in your application will be tracked.

  • Click Get Allocations to see a list of objects that have been allocated since you clicked on the Start Tracking button. You can click on Get Allocations again to append to the list new objects that that have been allocated.

  • To stop tracking or to clear the data and start over, click the Stop Tracking button.
  • Click on a specific row in the list to see more detailed information such as the method and line number of the code that allocated the object.

关于android - 如何找到创建字节数组的源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15460128/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com