Spawn process on deploy (0xc0000142 error)

Hello all!
I encountered a strange problem:
in our deploy process we have step with spawn process (80 instances) with powershell script
Write-Output ‘Starting…’

$controllerPath = $OctopusParameters["Deploy.ControllerInstallPath"]
$controllersCount = $OctopusParameters["Deploy.ControllersCount"]
$controllerExe = ($virtualControllerPath + '\' + 'Controller.exe')
$basePort = [int]$OctopusParameters["Deploy.controllersBasePort"]

Write-Output ("Total controllers: " + $controllersCount)

For ($i=1; $i -le $controllersCount; $i++) {	   
Start-Process $controllerExe (' ' + ($basePort + $i) + " TU000$i")

Write-Output 'Controllers ready'

we have two environment (test and staging) and two tenants (primary and secondary) for one of the environments (for staging).
Then we deploy to test environments all works fine, then we deploy to secondary tenant in staging environments - all works fine, but when we deploy to primary tenant in staging environment we cannot spawn more than 23 child process - all other process silently failure with error code 0xC0000142.

we also try to change script from powershell to c#, but result is same.

target machine run under win server 2016, so it is not this problem.

Hi Anatoly,

Thanks for getting in touch.

This sounds environmental to me, what is the difference between the two tenant machines? Can you run the script manually on the primary tenant’s machine as the Tentacle user?


there is no different between two tenants - in fact it run on same machine, different only in paths - we need to deploy two instances of application.
i also tried to run script manualy - all work fine - all process spawn and work correctly

Hi Anatoly.

That is very strange. Are you are deploying to the same Tentacle instance for both Tenants?

Is it always 23 child processes? Can you try running Tentacle from the command line rather then as a service to see if that works? Execute C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe run.


yes, the same tentacle instance.
it is always 23 child process… but i want to check another idea - i want to change tenants order, but i can test it only on Monday. i also check your suggestion.

ok, i checked suggestion…

  1. i try to change order of tenants - for the first (in order) tenants all processes start successful, for the second tenants i can see only 23 processes…
  2. when i launch tentacle as standalone exe (not service) all processes spawn correct (for each tenants)

it sound like windows has some limitation for process for system account

Hi Anatoly,

Shane is currently away on some well deserved holidays, so I’m just following up on your support ticket.

You are correct, there is a limit (and it all comes down the Desktop Heap in Windows) to the amount of processes a Windows Service can spawn. This Desktop Heap limit is much higher when you run in an interactive session.

There is a way to increase the Desktop Heap limit in the Registry, the reply marked as the answer in this post show the process to do this.

I hope that helps.

Thank you and best regards,

thank you! i think, that we should change our project structure, because changes in registry does not seem like a good idea.
but now i know about this limitation and that is the main point.
Great Job!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.