locked
Unknown build error, 'Exception of type 'System.OutOfMemoryException' was thrown.' RRS feed

  • Question

  • Good day.

    I am using Visual Studio 2008 Standard edition on Vista Business 32bit with a Intel Quad core machine and 4GB of RAM.

    We have a solution with 41 projects in it and I get this error at least twice a day: "Unknown build error, 'Exception of type 'System.OutOfMemoryException' was thrown.'"

    In the output window: "C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.WinFX.targets(294,9): error MC1000: Unknown build error, 'Exception of type 'System.OutOfMemoryException' was thrown.' "

    At this time the devenv.exe process is using 1014MB of memory (with a 1063MB peak) and I have 888MB free on the system (that is even before the pagefile comes into play) so this is not a system out of memory problem.

    I have had this problem before with a single project with too many resource files, so I suspect that the Resource Compiler is the one running out of memory.

    If I close Visual Studio and open the solution again everything works and the entire solution compiles (even if i do a clean and rebuild).

    Any ideas of what is going on here?

    Thank you very much.

    Thursday, October 9, 2008 8:23 AM

All replies

  • We are two developers working on the same solution (59 projects in the solution) and we get the excact same exception: 

    C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.WinFX.targets(294,9): error MC1000: Unknown build error, 'Exception of type 'System.OutOfMemoryException' was thrown.'

    Did you find a solution to the problem?

    Thanks,
    Klaus Enevoldsen

    Monday, February 16, 2009 11:35 AM
  • Same thing here with 42 projets in solution.

    Really annoying!

    Martin
    Friday, March 27, 2009 5:18 PM
  • Same thing here, with just 6 projects in our VS2008 SP1 solution.

    Interestingly, it throws this error when it tries to deploy the Database Project, when I try to run the 
    Web project in Debug mode.

    Is there a way to tell VS2008  "Look, the database already exists on my local SQL Server database.
    You know this, you deployed it last time.. and the time before... and the time before.  You don't
    need to do this each time I want to run my Web application" ?

    God, I can't wait 'til VS2008 is finished.   
    Maybe TFS will be as good as SourceSafe 6.0 by then...!!


    Quick addition: There's 9Gb free on my C: drive, and I have about 2Gb of free memory.

    Friday, April 24, 2009 8:46 AM
  • Same thing here, with just 6 projects in our VS2008 SP1 solution.

    Interestingly, it throws this error when it tries to deploy the Database Project, when I try to run the 
    Web project in Debug mode.

    Is there a way to tell VS2008  "Look, the database already exists on my local SQL Server database.
    You know this, you deployed it last time.. and the time before... and the time before.  You don't
    need to do this each time I want to run my Web application" ?

    God, I can't wait 'til VS2008 is finished.   
    Maybe TFS will be as good as SourceSafe 6.0 by then...!!


    Quick addition: There's 9Gb free on my C: drive, and I have about 2Gb of free memory.


    It gets worse.

    ------ Build started: Project: MikesApp.DatabaseProject, Configuration: Default Any CPU ------
    Building deployment script for ReP : EnableFullTextSearch, BlockIncrementalDeploymentIfDataLoss
    C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\TeamData\Microsoft.VisualStudio.TeamSystem.Data.Tasks.targets(105,5): Error MSB4018: The "SqlBuildTask" task failed unexpectedly.
    System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
       at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity)
       at System.Text.StringBuilder.GetNewString(String currentString, Int32 requiredLength)
       at System.Text.StringBuilder.Append(String value)
       at Microsoft.VisualStudio.TeamSystem.Data.Schema.SqlBuildTaskHelper.ReplaceSqlcmdMicros(String script, String baseDir)
       at Microsoft.VisualStudio.TeamSystem.Data.Schema.SqlBuildTaskHelper.ReadScriptFile(String scriptPath, StringBuilder stringBuilder)
       at Microsoft.VisualStudio.TeamSystem.Data.Schema.SqlBuildTaskHelper.GenerateProjectBuildScript()
       at Microsoft.VisualStudio.TeamSystem.Data.Tasks.SqlBuildTask.Execute()
       at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)
    Done building project "MikesApp.DatabaseProject.dbproj" -- FAILED.

    Build FAILED.
    ========== Build: 1 succeeded, 1 failed, 4 up-to-date, 0 skipped ==========


    Again, I haven't actually changed anything in the DatabaseProject all week.
    I don't even *want* to run the Database Project, but it is one of the Projects in my Solution.
    It's actually the Web project I want to run, but VS demands that it does the db project first..
    and fails miserably.




    Friday, April 24, 2009 9:00 AM
  • Any update on this?  I have nearly the same issue.

    [x86/Release] C:\SIRI\SIRI\Sources\Development\Eclipsys.SunriseXA.SIRI.sln(0,0): error MSB4018: The "MSBuild" task failed unexpectedly.
    System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
       at System.Collections.Hashtable..ctor(Int32 capacity, Single loadFactor)
       at System.Collections.Hashtable.Clone()
       at Microsoft.Build.BuildEngine.CopyOnWriteHashtable.get_WriteOperation()
       at Microsoft.Build.BuildEngine.CopyOnWriteHashtable.set_Item(Object key, Object value)
       at Microsoft.Build.BuildEngine.BuildItem.ImportVirtualMetadataFrom(BuildItem itemToCopyFrom)
       at Microsoft.Build.BuildEngine.BuildItem.CreateClonedParentedItem(BuildItem childItem, BuildItem parentItem)
       at Microsoft.Build.BuildEngine.BuildItem.Evaluate(Expander expander, String baseDirectory, Boolean expandMetadata, ParserOptions parserOptions, EngineLoggingServices loggingServices, BuildEventContext buildEventContext)
       at Microsoft.Build.BuildEngine.IntrinsicTask.ExecuteAdd(BuildItemGroupChildXml child, ItemBucket bucket)
       at Microsoft.Build.BuildEngine.IntrinsicTask.ExecuteItemGroup(Lookup lookup)
       at Microsoft.Build.BuildEngine.IntrinsicTask.ExecuteTask(Lookup lookup)
       at Microsoft.Build.BuildEngine.TargetExecutionWrapper.ExecuteIntrinsicTask(XmlElement taskNode)
       at Microsoft.Build.BuildEngine.TargetExecutionWrapper.ExecuteCurrentTask(ProjectBuildState buildContext)
       at Microsoft.Build.BuildEngine.TargetExecutionWrapper.ContinueRunningTasks(ProjectBuildState buildContext, TaskExecutionContext taskExecutionContext, Boolean startingFirstTask)
       at Microsoft.Build.BuildEngine.TargetExecutionWrapper.ContinueBuild(ProjectBuildState buildContext, TaskExecutionContext taskExecutionContext)
       at Microsoft.Build.BuildEngine.Project.ExecuteNextActionForProjectContext(ProjectBuildState buildContext, Boolean initialCall)
       at Microsoft.Build.BuildEngine.Project.CalculateNextActionForProjectContext(ProjectBuildState buildContext)
       at Microsoft.Build.BuildEngine.Project.ContinueBuild(ProjectBuildState buildContext, TaskExecutionContext taskExecutionContext)
       at Microsoft.Build.BuildEngine.Project.BuildInternal(BuildRequest buildRequest)
       at Microsoft.Build.BuildEngine.Engine.BuildProjectInternalInitial(BuildRequest buildRequest, Project project)
       at Microsoft.Build.BuildEngine.Engine.BuildProjectInternal(BuildRequest buildRequest, ProjectBuildState buildContext, TaskExecutionContext taskExecutionContext, Boolean initialCall)
       at Microsoft.Build.BuildEngine.Engine.BuildProjectFileInternal(BuildRequest buildRequest)
       at Microsoft.Build.BuildEngine.Engine.EngineBuildLoop(BuildRequest terminatingBuildRequest)
       at Microsoft.Build.BuildEngine.TaskExecutionModule.BuildProjectFile(Int32 handleId, String[] projectFileNames, String[] targetNames, IDictionary[] globalPropertiesPerProject, IDictionary[] targetOutputsPerProject, EngineLoggingServices loggingServices, String[] toolsVersions, Boolean useResultsCache, Boolean unloadProjectsOnCompletion, BuildEventContext taskContext)
       at Microsoft.Build.BuildEngine.EngineProxy.BuildProjectFilesInParallel(String[] projectFileNames, String[] targetNames, IDictionary[] globalProperties, IDictionary[] targetOutputsPerProject, String[] toolsVersions, Boolean useResultsCache, Boolean unloadProjectsOnCompletion)
       at Microsoft.Build.Tasks.MSBuild.ExecuteTargets(ITaskItem[] projects, Hashtable propertiesTable, ArrayList targetLists, Boolean stopOnFirstFailure, Boolean rebaseOutputs, IBuildEngine2 buildEngine, TaskLoggingHelper log, ArrayList targetOutputs, Boolean useResultsCache, Boolean unloadProjectsOnCompletion, String toolsVersion)
       at Microsoft.Build.Tasks.MSBuild.BuildProjectsInParallel(Hashtable propertiesTable, ArrayList targetLists, Boolean success, Boolean[] skipProjects)
       at Microsoft.Build.Tasks.MSBuild.Execute()
       at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)
    Tuesday, May 5, 2009 7:04 PM
  • Any updates?

    Getting this in a VS 2008 solution containing native C++ projects along with C# and C++/CLI projects. 37 projects in solution.
    Tuesday, May 19, 2009 10:36 AM
  • My project that is failing is a workflow project and there is some goofy memory management that is inconsistent between the IDE and TeamBuild. 

    You can use a command line task to use DEVENV to build the project and you don't have any issue.  This below was the solution from Microsoft with the Workflow projects but I think the underlying problem is a bug in my opinion and should be fixed properly:

    1. Create a file  c:\ProgramFiles\MSBuild\v3.5\Custom.After.Microsoft.Common.targets

     

    NOTE: Please do not modify the name or the location of the file above

     

    Add the following to the file Custom.After.Microsoft.Common.targets

     

    ****************************************************************

     

    <Project xmlns="http://schemas.microsoft.com/developer/MSBuild/2003">

        <PropertyGroup>

        </PropertyGroup>

        <Target Name="AfterClean">

                <CallTarget Targets="GetTargetPath" UseResultsCache="true"

    Condition="'$(UnloadProjectsOnCompletion)'=='true'"/>

        </Target>

        <Target Name="AfterBuild">

                <CallTarget Targets="GetTargetPath" UseResultsCache="true"

    Condition="'$(UnloadProjectsOnCompletion)'=='true'"/>

        </Target>

         <Target Name="AfterPublish">

                <CallTarget Targets="GetTargetPath" UseResultsCache="true"

    Condition="'$(UnloadProjectsOnCompletion)'=='true'"/>

        </Target>

    </Project>

     

    ***********************************************************

    2. In your tfsbuild.rsp file, add the lines

    /tv:3.5

    /p:UnloadProjectsOnCompletion=true

     

    Tuesday, May 19, 2009 4:04 PM
  • According to this post (http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=415151 ) this is an architectual issue in Visual Studio 2008, more specific Visual Basic but I've got the same problem in C#

    They propose some workarounds or advice to upgrade to Visual Studio 2010, sigh...
    Wednesday, January 13, 2010 9:49 AM
  • Same issue here, I see the Out of Memory Exception quite frequently. There are 7 projects in my solution. In previous versions of windows I would use the /3GB hack and make VS2008 Large Address Aware. However, I cannot find a way to do that on Windows 7.

    Will this exception go away in VS2010? If so I can wait until Monday and load the new version, if not I need a workaround. Thanks.

    Wednesday, April 7, 2010 3:38 PM
  • I am also facing the same issue qite frequently. I am about to try the solution provided here -

    http://confluence.jetbrains.net/display/ReSharper/OutOfMemoryException+Fix

    Lets see how it goes....


    Cheerio
    Wednesday, June 16, 2010 9:02 AM
  • i tried that, running that wrapper, still getting the same error

    Microsoft.WinFX.targets(294,9): error MC1000: Unknown build error, 'Exception of type 'System.OutOfMemoryException' was thrown.'

    Monday, August 9, 2010 6:21 AM