For the people that use the Visual Studio editor for software development that is a nice feature that in my experience I think is utilized by most developers that I have talked to about. In fact, most people do not even know about it. I recently became every familiar with it when I was trying to track down an annoying bug in Visual Studio that was driving me absolutely crazy for almost a week. I mainly do native C++ development in Visual Studio, but the Task List Window is available for many of the technologies and has added in the Visual Studio 2003 .NET. It allows you a way to manually or automatically add a shortcut and comment to a line code and so that you can just double-click to jump to that that code in your project. If the project/solution/file is not open then it will automatically be loaded. There are various tabs that let you view the various type shortcuts that you have set in Visual Studio. The shortcut type that was giving my fits last week was related to the manually added shortcut type that can be added to any line in a source file by pressing CTRL+K, CTRL+H (you press the control key twice) with the default settings for an unmanaged C++ file. When you do this you will see something like this in the editor after you add the shortcut. You can do this with the with the GUI too, you just need to open the Task List window (View àOther Windows àTask List) add you can add a shortcut from this panel: Sounds like a nice feature does is it not? Well, I thought so too and I started using it in file one source file we have a lot that is about 10K lines of code that I was in the process of trying to shorten. I went through some part of the file and added some shortcuts to a few lines where I want to go back to later when I had time to clean up some dead code or whatever. I did this in a few other files that I was actively working on too. Then, I got side-tracked and had to work on something else for a couple for a few months and never had to make any changes in this file in the meantime. But, recently I had to add a new feature and I had to make some changes in the big file that I added a few code shortcuts to. I had since forgotten that the last thing that I did in that file was add these shortcuts. So, I checked out the file and started to work on the a few changes that I needed make in this file and I immediately became annoyed with my computer because it was taking almost 2 second to either add or delete a line of text in the one file. I did not have this problem with any other files in my solution. No one else on my team could reproduce this problem. I thought at first it was because the file was so big that maybe Intellisense was slowing it down so I wrote a macro to turn it off and that did not help. I checked to see if the problem occurred with another file that was even larger and it did not. I was very busy and did not have to waste debugging this Visual Studio issue. I made a new copy of the file with the same contents and it did not happen in the new file, but if I renamed the file in the project the problem occurred in the renamed file. In meantime I was working a lot in this file and this issue was getting more and annoying. I started to think maybe I had a plugin that was install that causing this to happen so I was examining all the Visual Studio threads and found that there was this one thread that was using 12% of my i7’s CPU when I inserted or deleted a line of code. It did not happen when I did this with other files. I was able to figure out what the module name was in Visual Studio and that gave me a clue that it had something to do with the specific core code in VS. Since the problem happened at the top of the file and not at the bottom I decide to figure out which line the problem stopped occurring on. I did a binary search and quickly determined that at about line 6981 the problem did not occur and the higher I went up in the file the longer it took to insert and delete lines. Guess what I a saw a lot of in that area of code? I saw several of those blue arrows that indicate that this line of code as a shortcut in the task window. So, I went to my shortcuts task window and to my surprise I had 300 shortcuts defined. It was even more surprising when I found out that there really were only 3 different ones but each one had 99 other copies of the exact same shortcut. I know I did not do that because there is no way I know of in Visual Studio to add a duplicate shortcut. If you try and shortcut a line that is already has a shortcut to it then it is removed. It turns out that if you start adding shortcuts to your source file you will quickly see that it will not be long before you can notice that inserting and deleting lines will take just a bit longer when you are above the shortcuts. Once you have about 20, it starts to get a little annoying. So, there are a couple of issues with shortcuts in Visual Studio 2008. There is a bug somewhere that causes your task code shortcuts to be duplicated until you hit the 300 line max, which I can understand. You can’t catch every bug (it would be nice if I could report this bug, but Microsoft connect is not taking bugs on Visual Studio 2008, just 2010) and I stress the editor and have a few extra plugins and just recently installed a hotfix to fix another strange issue. I was thinking that the hotfix was the root cause of this issue (because I was only happening on one of my machines). What I don’t understand is why no one in QA tested adding 50 shortcuts to a file and see if that caused any performance issues. It certainly does, you can just open a new file and add 25 shortcuts to it and you will start to see what I was seeing. There is an easy workaround for this issue, you just have to delete all your shortcuts and stop using that VS feature. You can get the same functionality by putting the “TODO” token in your source file and VS will automatically create a non-CPU intensive shortcut in the Task Window. There is a hotfix that addresses a problem similar to this, but it was specific to a development technology I was not using in my solution. So, if you are having this problem, now you know why and how you can fix it. I hope this help someone else too. Thanks |

