That memory thing I promised you

Today Jeff Wilcox, David Anson, and I did a Channel 9 live session with Dan Fernandez at the PDC on Microsoft campus. You can catch it almost exactly 55 minutes into the stream here (note to self: try to remember what team you work on - it's the Application Platform team, not the Application Development team!)

One thing I mentioned was the LazyListBox, which you can find here, and the other ListBox virtualization samples that you can find on the Silverlight Performance blog here.

Anyway, I foolishly promised to publish something on my blog, so here it is. It's a simple class called MemoryDiagnosticsHelper that shows a counter similar to the built-in frame-rate counter that can be used to show how much memory you are using. It will also Assert if you go over the marketplace limit of 90MB, which is nice. It also ensures that the calls to DeviceExtendedProperties are only made in DEBUG mode so that you won't get a scary disclosure in marketplace for "identifying the device."

Anyway, the code is attached along with a very silly sample app. All you really need is the MemoryDiagnosticsHelper.cs file though, which you can pull into your existing apps and add a line like this in App.xaml.cs right under the call to EnableFrameRateCounter

MemoryDiagnosticsHelper.Start(TimeSpan.FromMilliseconds(500), true);

MemoryDiagnosticApp.zip