Open Your project
Open Solution explorer
Right click on project
Select Properties
Click on Build Event
You will see: Post-build event command line:
Add below lines of script inside that box..
call "$(DevEnvDir)..\..\vc\vcvarsall.bat" x86
"$(DevEnvDir)..\..\vc\bin\EditBin.exe" "$(TargetPath)" /LARGEADDRESSAWARE
Now click on "Debug"
Under Enable debuggers
check: "Enable Visual studio Hosting Process"
Save
Now run your project, you will not see system.outofmemoryexception error
Ref:http://blogs.msdn.com/b/calvin_hsia/archive/2010/09/27/10068359.aspx