Visual Studio 2017/2019: OutOfMemoryException error during Rebuild

My projects on Visual Studio Community 2017 and 2019 suddenly having OutOfMemoryException error during Rebuild. I have already tried these but issue wasn’t resolved.

1. Uninstalling and reinstalling these IDEs and all Visual Studio SDKs.

2. Deleted the folders .vs, bin, obj from the project folders before solution Rebuild.

3. Deleted .IdentityService folder from the Windows AppData folder before solution Rebuild.

My machine’s memory has 16GB. Before, even at 80 – 90% usage, I didn’t have the error.

VS Community 2019

1>—— Rebuild All started: Project: [PROJECT NAME], Configuration: Debug Any CPU ——

1>C:\[PROJECT DIRECTORY]\packages\Microsoft.Net.Compilers.1.0.0\tools\Microsoft.CSharp.Core.targets(67,5): error :

1>C:\[PROJECT DIRECTORY]\packages\Microsoft.Net.Compilers.1.0.0\tools\Microsoft.CSharp.Core.targets(67,5): error : Unhandled Exception: OutOfMemoryException.

VS Community 2017

1>—— Build started: Project: [PROJECT NAME], Configuration: Debug Any CPU ——

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(52,5): error :

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets(52,5): error : Unhandled Exception: OutOfMemoryException.

Read more here: Source link