System.OutOfMemoryException thrown while building a large C# solution using Visual Studio 2005 SP1 IDE.

Article translations Article translations
Close Close
Article ID: 949755 - View products that this article applies to.
Expand all | Collapse all
Source: Microsoft Support

RAPID PUBLISHING

RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.

Action

Created a large managed solution using Visual Studio that contains many managed projects inside.  The size of the solution can be greater than 300 MB depending on what's in each project in the solution.  The size can variety due to the nature of the problem. 

Result



When building such a large solution from the IDE, the build may fail with OutOfMemoryException. The output window contains the following error message.


The "GenerateResource" task failed unexpectedly.
System.OutOfMemoryException: Exception of type "System.OutOfMemoryException" was thrown.



Cause

The solution size is the root cause of the problem.  This is a limitation memory usage in any process.  What is happening here is that the IDE is loading all files into memory and running out of process memory to continue due to the size of the solution.  A process can ideally allocate 4 GB memory in 43 bit, but that is divided into 2 GB for user and 2 for kernel.  When the process gets close to 2 GB memory usage it will throw OutOfMemory exception.

Resolution

Reducing the solution size by removing one project or a few projects will resolve the issue.  Having many projects in a single solution is not good practice as well.

More Information

Structuring Solutions and Projectshttp://msdn2.microsoft.com/en-us/library/ms998208.aspx

DISCLAIMER

MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.

TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.

Properties

Article ID: 949755 - Last Review: February 26, 2008 - Revision: 1.2
APPLIES TO
  • Microsoft Visual Studio 2005 Standard Edition
  • Microsoft Visual Studio 2008 Standard Edition
Keywords: 
kbnomt kbrapidpub KB949755

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com