I would not be wrong if I say that most computers these days are 64 bit. 64 bit offers many advantages over 32 bits and in general there is not much sense to install 32 bit OS pretty much anywhere, except maybe for some 32 bit virtual machine with less than 4 Gb of RAM, because in general 32 bit OS takes less memory. But even then, it is better to have 64 bit and just have couple of services running on it.

But at the same time, it is still common to run 32 code on it. For example, if you have IIS in many cases it has sense to run 32-bit worker process. Main reason behind that 32-bit

Recently I got email from customer, that our product consumes relatively lot of CPU on idle. About 3%-7%. He is using old notebook and as result fan is constantly cycles between on and off state and it is really annoying. I decided to check this because very often it could be sign of bigger problems.

Usually for cases like this I am asking customer to run PerfView to collect events that happens during problematic time. It is quite useful application; it is developed by Microsoft and completely free. It has quite unusual interface and requires some learning. There have links to learning videos from app itself.

Anyway, customer was nice and provided quite a few PerfView captures in different state

Case of frozen PeekMessage

Recently I was investigating why our application freezes during certain operations. After collecting few dump files, I found that every single time application freezes in quite old code that was written about 20 years ago. Loading documents could be quite long, and some person decided that it would be good idea if user can press Escape and cancel loading. To detect key press, that code calls something like this:
PeekMessage(Msg, CurrentFormHandle, WM_KeyFirst, WM_KeyLast, PM_Remove Or PM_NoYield)

Callstack looks like this:


It looks quite innocent and I do not see any reason why it should hang. After some thinking I came with two theories:

  1. CurrentFormHandle returns invalid window handle that got reused by some thread that is sleeping
  2. Code that calls PeekMessage has infinite loop and PeekMessage is just took more time and appears in crash dumps.

Recently I found code that looks like this:

        static async Task Main(string[] args)
            const int MaxLines = 10000;
            string line;
            List<string> lines = new List<string>();
            Stopwatch stopwatch = Stopwatch.StartNew();

            using var reader = new StreamReader(args[0]);
            while ((line = await reader.ReadLineAsync()) != null)
                if (lines.Count >= MaxLines)



As you can see this code is written “by the book”, everything is async: Main function is async, reading from file is async, and looks like this code is good. And if you ask people around which version would be faster: this one or non-async you will get mixed result. Some will say that async version will be faster,