Have a question? Email Us or Call 1 (800) 936-2134
SubMain - Code Quality Tools, Automated Code Review and Refactoring Home Products Services Download Purchase Support Community

Avoiding Out of Memory Exceptions in Visual Studio

Starting CodeIt.Rigth v1.8 (10/28/2009) we have added "Memory Optimization" mode that addresses majority of the "Out Of Memory" scenarios (albeit not all). Before you follow instructions in the article below first try to change CodeIt.Right -> Options -> Perfomance setting to Memory Optimizion and see if that helps. This mode is recommended for larger solutions as it has significantly lower memory compsumption with only slightly lower performance.

As you may know Visual Studio requires quite a bit of memory resources, especially if your solution is fairly large and you have some Add-Ins installed. Since all Add-Ins run in the Visual Studio address space, they too add up to the Visual Studio memory use which is limited to 2GB of virtual memory. This is true even when you are running Visual Studio on a 64-bit OS because VS is still a 32-bit application.

When Visual Studio + all Add-Ins memory use gets close to the 2GB limit it throws the OutOfMemoryException which cannot be caught nor handled. Then Visual Studio closes and you lose all unsaved changes.

To address this issue to an extent you can make Visual Studio use up to 3GB of virtual memory.

First of all, tell the OS to increase the amount of user-mode memory from 2GB to 3GB. (If you are running on 64-bit, skip this step)

  • For Windows XP: Backup boot.ini and add /3GB switch. For example:
    multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows XP" /fastdetect /3GB
  • For Vista: Run the following from the command prompt:
    BCDEDIT /Set IncreaseUserVa 3072

Next is we need to make Visual Studio large address awaer:

  • Be sure to backup devenv.exe
  • From the command prompt navigate to "C:\Program Files\Microsoft Visual Studio 9\Common7\IDE" (your actual path may vary depending on version of Visual Studio and install path) and execute the following:
    editbin /LARGEADDRESSAWARE devenv.exe
  • Reboot your computer
 

 
     
 
Home |  Products |  Download |  Purchase |  Support |  Privacy |  Terms |  About Us |