Visual Studio can require quite a lot of memory. This is especially true if your solution is fairly large or you are accidentally including a bit to much of your database (opps!). The important thing to realize is that even if you have a lot of memory, the Visual Studio IDE (as of 2011 at least) is still a 32 bit application. Once it gets to the 2 GB limit, it starts throwing those annoying OutOfMemory exceptions which can not be handled or caught. Usually at this point, it will eventually crash. This can make it very hard to even find and remove the offending code (if possible).
The solution turns out to be to extend the virtual memory to 4GB. To do this, you just need to do a few things:
Open a command line as administrator and change to “C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE”.
Then execute “editbin /LARGEADDRESSAWARE devenv.exe”
If you get an exception that it can not find mspdb100.dll, run “C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat” to load the dll.