GitVersion: MSBuild crashes with an out-of-memory exception when updating GitVersionTask from 4.0.0-beta0013 to 4.0.0
Problem:
MSBuild.exe crashes with an out-of-memory exception frequently when we try to upgrade GitVersionTask from 4.0.0-beta0013 to 4.0.0.
Preconditions:
- The Git repository should be large in terms of number of commits, our repo has > 80k commits.
- MSBuild.exe runs as a 32-bit process. We use the MSBuild supplied with
VS2015.
Observations:
- We observed that
GitVersionTask-4.0.0consumes about1.2GBof memory, whereasGitVersionTask-4.0.0-beta-0013consumes200MB. GitVersion.CommandLinecontinues to consume the same amount of memory in both the versions. So we believe that updates toGitVersionTaskbetween these two versions causes the problem.GitVersionTask-4.0.0relies onUtilPack.NuGet.MSBuild, could this cause the problem somehow?
This issue is preventing us from upgrading GitVersion and we would really appreciate some feedback or workarounds for this issue.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (17 by maintainers)
I am sure this is something that can be improved. The
NuGetUtils.MSBuild.Execspawns 3 processes on first run of any task it uses, and 1 process per subsequent run of the similar tasks within the same MSBuild process. If you invoke MSBuild process many times during the build, theNuGetUtils.MSBuild.Execloses the cached information and ends up spawning more processes than required. So that one way to improve build times is to minimize the amount of MSBuild invocations.I will also add some diagnostic output for all situations
NuGetUtils.MSBuild.Execinvokes processes, so that this behaviour can be better tracked, and improved in the future. The current work is only first iteration of the idea of using processes to invoke dynamic tasks in NuGet packages and I am sure there is still plenty of room for improvement.I’ve published version
2.0.2ofNuGetUtils.MSBuild.Execand updatedGitVersionTaskto use that version. TheUpdateAssemblyInfotask now executes successfully.Interesting, I had to explicitly set property
UpdateAssemblyInfototrueto reproduce this. But - now I have a repro and will work on it, stay tuned! This seems to be related to howITaskItems are used in generated task type.I know @stazz has an ongoing PR which will change the way gitversiontask works. Once his PR is stable it would be good to try that version to see if memory consumption remains an issue