4
votes

I have a .NET Framework ASP.NET application running in IIS. The application launches a long-lived sub-process but is otherwise unremarkable (just one endpoint which effectively proxies requests to the sub-process).

While the system is serving requests, the memory usage for conhost.exe on the machine steadily rises (~linear growth); after about a day it will be consuming .5-1 GB. Every 29 hours, the IIS application pool automatically recycles itself; at this point the conhost usage drops back to zero but then starts steadily growing again.

What could cause conhost to use this much memory?

UPDATE:

I saw that the settings for Console.BufferWidth and Console.BufferHeight can lead to more memory usage in conhost.exe. Therefore, I added logging for these values. However, my app shows a constant small buffer width and height.

UPDATE:

Per @simon-mourier's comment we pulled the dlls attached to the conhost process. All are in System32. The list is: conhost, ntdll, kernel32, kernelbase, msvcrt, Conhostv2, combase, ucrtbase, RPCRT4, bcryptPrimitives, GDI32, gdi32full, USER32, win32u, IMM32, OLEAUT32, msvcp_win, PROPSYS, sechost, shcore, SHELL32, cfgmgr32, windows.storage, powerprof, advapi32, shlwapi, kernel.appcore, and profapi.

UPDATE:

Seems similar to (if not the same as) ASP.NET Core ILogger Memory Leak on Windows 10 (1607) / Windows Server 2016 . Unfortunately that also lacks answers.

1
Does your ASP.NET application create any subprocesses (Typically with Process.Start() but there are other ways)? Would the executables it is spawning as subprocesses happen to be console applications? - Ben Voigt
@BenVoigt yes the subprocess spawns is a console application. - ChaseMedallion
@BenVoigt any theory as to why that would cause conhost.exe to leak? The subprocess itself does not seem to be leaking memory. - ChaseMedallion
You can check the dll attached to this conhost.exe process (using Process Explorer tool from sysinternals for example) see if anything looks suspicious (3rd party dll, etc.) - Simon Mourier
@ChaseMedallion Sorry for the late reply, I posted an answer how to fix the issue I had: stackoverflow.com/a/68577179/779506 OS version is indeed relevant, thus if your issue is only happening on Server 2016 this might be related. - sky

1 Answers

1
votes

This turned out to be a Windows OS bug. We contacted Microsoft support about the issue and received a patch (likely the same patch mentioned by @sky in stackoverflow.com/a/68577179/779506).