Android ships with a debugging tool called the Dalvik Debug Monitor Server (DDMS), which provides port-forwarding services, screen capture on the device, thread and heap information on the device, logcat, process, and radio state information, incoming call and SMS spoofing, location data spoofing, and more.
Below I have explained how to use few of the most useful services in DDMS
- Viewing heap usage for a process
- DDMS allows you to view how much heap memory a process is using. This information is useful in tracking heap usage at a certain point of time during the execution of your application.
- To view heap usage for a process:
- In the Devices tab, select the process that you want to see the heap information for.
- Click the Update Heap button to enable heap information for the process.
- In the Heap tab, click Cause GC to invoke garbage collection, which enables the collection of heap data. When the operation completes, you will see a group of object types and the memory that has been allocated for each type. You can clickCause GC again to refresh the data.
- Click on an object type in the list to see a bar graph that shows the number of objects allocated for a particular memory size in bytes.
- 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.
- 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.
- Examining thread information
The Threads tab in DDMS shows
you the currently running threads for a selected process.
- In the Devices tab, select the process that you want to examine the threads for.
- Click the Update Threads button.
- In the Threads tab, you can view the thread information for the selected process.
- Starting method profiling
Method profiling is a means
to track certain metrics about a method, such as number of calls,
execution time, and time spent executing the method.
To start method profiling:
- On the Devices tab, select the process that you want to enable method profiling for.
- Click the Start Method Profiling button.
- Interact with your application to start the methods that you want to profile.
- Click the Stop Method Profiling button. DDMS stops profiling your application and opens Traceview with the method profiling information that was collected between the time you clicked on Start Method Profiling and Stop Method Profiling.
0 comments:
Post a Comment