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.0 consumes about 1.2GB of memory, whereas GitVersionTask-4.0.0-beta-0013 consumes 200MB.
  • GitVersion.CommandLine continues to consume the same amount of memory in both the versions. So we believe that updates to GitVersionTask between these two versions causes the problem.
  • GitVersionTask-4.0.0 relies on UtilPack.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)

Most upvoted comments

I am sure this is something that can be improved. The NuGetUtils.MSBuild.Exec spawns 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, the NuGetUtils.MSBuild.Exec loses 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.Exec invokes 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.2 of NuGetUtils.MSBuild.Exec and updated GitVersionTask to use that version. The UpdateAssemblyInfo task now executes successfully.

Interesting, I had to explicitly set property UpdateAssemblyInfo to true to reproduce this. But - now I have a repro and will work on it, stay tuned! This seems to be related to how ITaskItems 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