How to find the source that created byte arrays

Using DDMS and creating HPROF, I see a “histogram” of the data representation in my application and noticed an excessive number of very large “byte []” objects. I suspect this is the result of an error or other stupidity in my code. But I do not know how to view the names of these byte objects or view the location in my source code where they were created. It can be done?

+4
source share
1 answer

Take a look here: Tracking the distribution of DDMS objects, it determines in stages how to track the distribution of objects and find a line of code for it.

Tracking object memory allocation

DDMS provides a function for tracking objects that are allocated to memory, and to determine which classes and streams allocate objects. This allows you to track in real time when objects are highlighted when performing certain actions in your application. This information is important for evaluating memory usage, which can affect application performance.

To track memory allocation by objects:

  • On the Devices tab, select the process for which you want to enable location tracking.
  • On the Allocation Tracker tab, click the Start Tracking button to begin tracking distribution. At this stage, everything that you do in your application will be tracked.

  • Click Get Distributions to view a list of the objects that have been selected since you clicked Start Tracking. You can click Get Distributions again to add new objects to the list that have been selected.

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

All Articles