The Remote Performance Monitor (RPC) application is truly awesome ! Ever had your Windows Mobile applications report memory problems? Well this baby can show you where your problems could reside. This blog will show you how to setup the RPC with Visual Studio and remotely check its performance (without even using a proper PDA) !
For this you will need Power Toys for .NET Compact Framework 3.5 which can be downloaded from;
Create the SmartDevice Application
In Visual Studio, select File->New->Project. From the list, select the SmartDevice item and give it a Meaningful name.
Once the designer has finished loading, drag a Button and a TextBox onto the main form.
Double click the Button to create an On Click event handler in the codebehind.
Next, add a private string to the Form1 class (any name will do)
In the newly created event handler, enter the following snippet
private void button1_Click(object sender, EventArgs e)
{
_simpleString += Guid.NewGuid().ToString();
textBox1.Text = _simpleString;
}
So now, we have an event handler which will add a new Guid to the _simpleString every time we press the button. I used string, as its an immutable type and will create a new reference to the string value every time we call the += operator. We should see how this effects the memory on the PDA using the RPC.
Deploy to Emulator
Now, open up the RPC.
Next press the Green Play button. You will be presented with the following Dialog;
Now, in the "Deploy Application From" TextBox, type the path of the newly created SmartClient (debug or release, whichever solution configuration you chose).
In the "Application Text Box" enter the executable name, then press "OK".
This will deploy the application to the PDA (Emulator) and run it. (You may have to deploy the .NET CF Framework first, do this from the Device Menu option, select the Visual Studio tree node and then select the "Windows Moile 5.0 Pocket PC R2 Emulator". Then press CTRL-I).
When your application runs on the PDA, you will see the RPC spring into action. Now select the "GC- Managed Objects allocated" and press the Button1 on the PDA Emulator. You will see the amount of Allocated memory increase. Now, you can keep clicking this and watching the memory increase until the GC reaches its 1st level of collection, a re-cycles.
To check the heap out, click the GC Heap button on the toolbar of the RPC; you can then drill down to specific objects on the heap; Choose System.String and hit the refresh button.
Awesome, you can now poke around in the PDAs Memory, JIT, GC etc all remotely. How awesome is that? you can of course deploy your troublesome application in the same way, and run through the motions until you reproduce the problem. Keeping an eye on the PDA's .NET workings at the same time, you should be able to get one step closer to finding out what the issue is.
Enjoy !
No comments:
Post a Comment