terminal/src/server
Leonard Hecker 8779249b12
Release unneeded memory more eagerly from conhost (#10738)
The `_CONSOLE_API_MSG` buffer is resized to cover an entire message.
Later on any UTF-8 data is cached in a separate temporary
buffer inside `til::u8state` to prevent lone surrogate pairs.

Both cases are problematic as neither buffer is freed after the read
has finished. Passing a 100MB buffer to conhost once will thus cause it
to continue using ~220MB of physical memory until the conhost process exits.

This change releases unneeded memory as soon as the requested buffer
size has halved. In practice this means that once a command has returned
all buffers will shrink, as the shell commonly sends very small messages.

## PR Checklist
* [x] Closes #10731
* [x] I work here
* [x] Tests added/passed

## Validation Steps Performed

* Buffers aren't reallocated during printing ✔️
* Buffers shrink after printing finished ✔️
2021-07-21 05:59:57 +00:00
..
lib Create a control unittesting project (#9677) 2021-04-05 16:07:55 +00:00
ApiDispatchers.cpp Set keyword flags on all tracelog events (#10098) 2021-05-14 23:14:26 +00:00
ApiDispatchers.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
ApiDispatchersInternal.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
ApiMessage.cpp Release unneeded memory more eagerly from conhost (#10738) 2021-07-21 05:59:57 +00:00
ApiMessage.h Remove CONSOLE_API_MSG::UpdateUserBufferPointers hack (#10326) 2021-06-14 19:52:40 +00:00
ApiMessageState.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ApiMessageState.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ApiSorter.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ApiSorter.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ConDrvDeviceComm.cpp ci: fix spelling 2021-02-11 14:08:37 -08:00
ConDrvDeviceComm.h Merged PR 5677497: [Git2Git] Merged PR 5655213: Allow conhost to handoff to registered default app handler 2021-02-11 21:07:50 +00:00
ConsoleShimPolicy.cpp Reintroduce a color compatibility hack, but only for PowerShells (#6810) 2020-07-10 15:25:39 -07:00
ConsoleShimPolicy.h Reintroduce a color compatibility hack, but only for PowerShells (#6810) 2020-07-10 15:25:39 -07:00
DeviceComm.h Merged PR 5677497: [Git2Git] Merged PR 5655213: Allow conhost to handoff to registered default app handler 2021-02-11 21:07:50 +00:00
DeviceHandle.cpp Apply audit mode to TerminalConnection/Core/Settings and WinCon… (#4016) 2020-01-03 10:44:27 -08:00
DeviceHandle.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
Entrypoints.cpp Change NULL to nullptr since they are pointers (#4960) 2020-03-20 20:35:12 +00:00
Entrypoints.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
IApiRoutines.h Replace basic_string_view<T> with span<const T> (#6921) 2020-07-15 16:40:42 +00:00
IWaitRoutine.h Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
IoDispatchers.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
IoDispatchers.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
IoSorter.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
IoSorter.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
IoThread.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ObjectHandle.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
ObjectHandle.h Prevent cleanup of object given to handle that failed access check (#3414) 2019-11-05 14:22:55 -08:00
ObjectHeader.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
ObjectHeader.h Prevent cleanup of object given to handle that failed access check (#3414) 2019-11-05 14:22:55 -08:00
ProcessHandle.cpp Convert DeviceComm into an interface and add handle exchange (#8367) 2020-12-15 23:07:43 +00:00
ProcessHandle.h Convert DeviceComm into an interface and add handle exchange (#8367) 2020-12-15 23:07:43 +00:00
ProcessList.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
ProcessList.h Revert locking changes (#3488) 2019-11-08 13:44:52 -08:00
ProcessPolicy.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
ProcessPolicy.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
WaitBlock.cpp Remove CONSOLE_API_MSG::UpdateUserBufferPointers hack (#10326) 2021-06-14 19:52:40 +00:00
WaitBlock.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
WaitQueue.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
WaitQueue.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
WaitTerminationReason.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
WinNTControl.cpp Apply audit mode to TerminalConnection/Core/Settings and WinCon… (#4016) 2020-01-03 10:44:27 -08:00
WinNTControl.h Apply audit mode to TerminalConnection/Core/Settings and WinCon… (#4016) 2020-01-03 10:44:27 -08:00
dirs Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
precomp.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
precomp.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
sources.inc Merged PR 5677497: [Git2Git] Merged PR 5655213: Allow conhost to handoff to registered default app handler 2021-02-11 21:07:50 +00:00
winbasep.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00