Dalvik Debug Monitor Server

jim-wilson-v5

Welcome to Part 4 of this review of the Pluralsight course Android for .NET Developers: 1 Getting Started by Jim Wilson

Jim has over 30 years of software engineering experience, with the past 15 years heavily focused on creating mobile device and location-based solutions. He has co-founded multiple software-related startups and has served in a consulting role at several more.

After nearly a decade as a Microsoft Device Application Development MVP, Jim now focuses on developing Android and iOS device applications. Jim’s passion is mentoring software developers. He blogs at hedgehogjim.wordpress.com.

Also in this series:

Part 1 – Series Overview
Part 2 – Setting up your environment
Part 3 – Android Toolset Fundamentals
Part 4 – Dalvik Debug Monitor Server
Part 5 – Understanding Android Projects
Part 6 – Android Studio
Part 7 – Understanding Android Versioning

Dalvik Debug Monitor Server (DDMS)

What is DDMS?

DDMS is a tool that provides a wide variety of debugging features, and its layout features three main sections:

1. List of connected devices and AVDs
2. Tools tab
3. Logcat View

For processes to be visible, debugging must be enabled.

We see the tools architecture diagram from the beginning of the last module again, and Jim explains the relationship and interaction between DDMS and our App.

Like .NET, Java runs a virtual machine. Each process gets its own copy of the Dalvik virtual machine. ADB connects to each virtual machine individually.

DDMS can reach inside of each virtual machine and see everything that’s going on. Jim says the ADB environment actually connects into the Android OS itself, allowing it to work very closely with the operating system.

DDMS is a set of tools. They give us visibility of:

– Memory usage
– Thread activity
– Network activity
– Access device.AVD file system
– Screen capture
– AVD control

In this we look at the most important, or commonly used, tools

To learn them all see https://developer.android.com/studio/profile/ddms.html

Memory usage

Jim explains that two primary memory usage tools that DDMS provides:

1. The heap view for a high-level view of the ap’s general memory usage
2. Allocation Tracker for a detailed object by object memory allocation information

Jim likes to use the allocation tracker more often than the heap view.

He demonstrates using them from Eclipse by switching to the DDMS perspective.

We see tabs for Thread, Heap, Allocation Tracker, Network, File Explorer and others.

To see the heap information we click the Update Heap button. Jim warns that this has a big negative effect on your application performance.
He turns it off and moves to the Allocation Tracker tab and we see the effect of clicking the “Get Allocations” button.
We also learn about the Include trace checkbox.

Threads

The threads viewer shows the threads running in your app ach each thread’s current call stack. Jim demonstrates how to use it. We click Update threads and it monitors the threads and their activity.

Jim says Method Profiling is outside the scope of this course but it is explained in the DDMS documentation.

Network activity

DDMS allows us to see our network statistics, i.e. data sent and received by the app. Jim demonstrates this in Eclipse.

We see there is a speed dropdown with “Medium (250ms)” selected. This means it updates four times a second. We can click the start button and see a graph rendering our network activity.

File system

The file explorer allows us to view and navigate the file system. At the top right corner of the file explorer there are some buttons.

These allow us to transfer files to and from our device, delete a file or folder, and create a new folder.

Screenshot

Screen capture creates a static image of the selected device.

We can refresh to get a new screen capture, rotate by 90 degrees, save to file, and copy an image to the clipboard.

Emulator control

Jim says there are some things that we can test with an emulator even more easily than with a real device. We can do things such as:

– change cellular radio behavior
– simulate radio transfer rate and delay
– simulate phone calls and text messaging
– set the current GPS coordinates
– use GPX or KML file formats to simulate GPS feed

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s