Turn your tests into stress tests easily

It’s great to be able to write tests and execute them while developing a project. While I’m developing, I can hit a button and run the dozens of tests to see if I’ve broken anything. As code gets written lots of things get refactored, moved around, etc. Hitting a button to see if I broke…


The number of Garbage Collections indicate how much memory is used

One of the performance improvements we made in .Net was with System.Text.StringBuilder. StringBuilder is used in lots of code to build strings: it has various methods to modify strings quickly. Once a string is built, the ToString method is called to create the string. We observed via MemSpect that there were thousands of instances of…


Performance of Memory vs Disk

There is a comment on this Visual Studio Blog post (about how we made Visual Studio faster): “Focus on speed, not memory usage. Memory is very cheap, but CPU performance is muuuuuuuuch moooooooore expensive.” Yes, memory keeps getting cheaper, but actually, reducing memory use is critical to increasing the performance of any large application like…


Examine the layout of managed strings in memory

Suppose you wrote some C# code like this: var str1 = "ThisIsAString"; var str2 = "ThisIsAnotherString"; As you’d expect, each string is stored in the resulting built binary and also in memory when the binary is loaded, resulting in 2 separate strings. Now suppose you wrote this code instead: var str1 = "ThisIsAString"; var str2…


Increase the memory available to your tests

    I love having test projects included in my solutions. Software is alive. I’m constantly making improvements/changes/fixes. When I have customers asking for various features in my code, or for code improvements, being agile and able to publish a changed build with utmost confidence relies largely on a great set of tests that can…

1

Examine your program’s available memory: is it leaking?

  Sometimes your program wakes up and finds itself running in an environment that might not be as suitable as you’d like.   For example, it might be distributed to a user running on a machine with not enough memory, and could be failing. Perhaps the failures occur because the user is running multiple applications…


Be careful about nothing in managed code

  Here’s a pattern of code use I’ve seen in a few places. There’s a function DeserializeList that returns an array of various sizes, depending on the input. This code can be called to deserialize (rehydrate) an object from a stream. For example, an XML deserializer might create an XML node from a binary stream….


Dynamically create huge tooltips in WPF TreeView and ListView

  Tooltips are useful. When the mouse hovers over a button a tip can indicate what happens when it’s clicked. The mouse move does not actually invoke the button, but can give information in a passive way.   Sometimes I want to make huge tooltips. This essentially gives more screen real estate for presenting a…


Use colors in WPF to show virtual memory fragmentation

In this post What is your computer doing with all that memory? Write your own memory browser is sample code that shows how to create a WPF grid view of a memory map of a process. You can click on a column header to sort, and you can see the various loaded images and even…


The cost of using nothing

What is the cost of using nothing? Seems like a silly question.   Suppose you see code like this:   void *  MyClass::DoSomething() { int size = sizeof(MyThing) * m_NumItems; var ptr = malloc(size); return ptr;}   It’s a method that allocates space for m_NumItems  MyThings.  This is a real code pattern that exists in…