Here’s another little gem I’ve got for you.

As you probably know, Visual Studio is a big product, with contributions coming from many many different teams, and languages. A big part of Visual Studio is written in managed languages these days, and there are a ton of 3rd party components that you can download and install from the VS Gallery that are also written in managed languages. As such, there are lots of developers out there writing managed components targeting the Visual Studio “runtime” if you will.

When testing code that is run in a managed runtime, sometimes it is quite helpful to force the runtime to garbage collect. The CLR has always had API that you could use to programmatically force a GC, but wouldn’t it be great if there was a way to force the runtime inside Visual Studio’s address space to collect via a simple keystroke?

Well there is. Ctrl-Alt-Shift-F12, twice, does exactly that.

So again, you have to hold down ctrl-Alt-Shift and then hit F12 twice in order to make Visual Studio garbage collect.

UPDATE ( 12/16/2010 ):

One thing I should have mentioned when I originally posted, was that if you don’t like that default mapping, or a 3rd party has overridden that mapping and you can’t find what key stroke the ForceGC command is mapped to, you can always check the Visual Studio key mappings by selecting Tools->Customize…, then hit the “Keyboard…” button:


…which takes you to the “Options” dialog where you can type “ForceGC” in the “Show Commands” text box and remap to whatever keystroke you’d like!