Severe Memory Leak, Possibly Related to UIA #20710

Closed
opened 2026-01-31 07:21:51 +00:00 by claunia · 5 comments
Owner

Originally created by @Simon818 on GitHub (Oct 21, 2023).

Windows Terminal version

1.19.2682.0

Windows build number

10.0.19045.3570

Other Software

NVDA 2023.3

Steps to reproduce

With NVDA running, open several terminal windows and leave them running for a few hours. Occasionally check the usage of the WindowsTerminal.exe process. The terminal windows do not need to be particularly active, though they should have something more than just a command prompt window running on them--perhaps SSH sessions or WSL windows.

Expected Behavior

Windows Terminal should remain within reasonable memory usage.

Actual Behavior

On my system, Windows Terminal's memory usage grows to hundreds of megabytes over time, causing responsiveness issues in Terminal and seemingly affecting the responsiveness of NVDA's UIA access. If I leave a terminal window open overnight, it and all other Terminal windows are nearly unusable the next morning, and the responsiveness of NVDA itself is affected, leaving core OS functionality unusable until I close the process. This leads me to believe the issue is related to UIA.

CC @carlos-zamora @codeofdusk

Originally created by @Simon818 on GitHub (Oct 21, 2023). ### Windows Terminal version 1.19.2682.0 ### Windows build number 10.0.19045.3570 ### Other Software NVDA 2023.3 ### Steps to reproduce With NVDA running, open several terminal windows and leave them running for a few hours. Occasionally check the usage of the WindowsTerminal.exe process. The terminal windows do not need to be particularly active, though they should have something more than just a command prompt window running on them--perhaps SSH sessions or WSL windows. ### Expected Behavior Windows Terminal should remain within reasonable memory usage. ### Actual Behavior On my system, Windows Terminal's memory usage grows to hundreds of megabytes over time, causing responsiveness issues in Terminal and seemingly affecting the responsiveness of NVDA's UIA access. If I leave a terminal window open overnight, it and all other Terminal windows are nearly unusable the next morning, and the responsiveness of NVDA itself is affected, leaving core OS functionality unusable until I close the process. This leads me to believe the issue is related to UIA. CC @carlos-zamora @codeofdusk
Author
Owner

@lhecker commented on GitHub (Oct 21, 2023):

Possible cause: This doesn't release any memory
https://github.com/microsoft/terminal/blob/main/src/renderer/uia/UiaRenderer.cpp#L234

If it's due to that, we could limit to either 4KiB or 2x the previous write size, whatever is larger (as an example):

if (_newOutput.capacity() >= std::max<size_t>(4096, _queuedOutput.size() * 2))
{
    _newOutput = std::wstring{};
    _newOutput.reserve(2048);
}
@lhecker commented on GitHub (Oct 21, 2023): Possible cause: This doesn't release any memory https://github.com/microsoft/terminal/blob/main/src/renderer/uia/UiaRenderer.cpp#L234 If it's due to that, we could limit to either 4KiB or 2x the previous write size, whatever is larger (as an example): ```cpp if (_newOutput.capacity() >= std::max<size_t>(4096, _queuedOutput.size() * 2)) { _newOutput = std::wstring{}; _newOutput.reserve(2048); } ```
Author
Owner

@carlos-zamora commented on GitHub (Oct 24, 2023):

Thanks @Simon818. Could you capture a memory dump for us? We have a guide for that right here: https://github.com/microsoft/terminal/wiki/Troubleshooting-Tips#capturing-and-sending-dumps

@carlos-zamora commented on GitHub (Oct 24, 2023): Thanks @Simon818. Could you capture a memory dump for us? We have a guide for that right here: https://github.com/microsoft/terminal/wiki/Troubleshooting-Tips#capturing-and-sending-dumps
Author
Owner

@zadjii-msft commented on GitHub (Oct 30, 2023):

I'm gonna give @Simon818 another week to try and get back to us here. This sounds really painful, but we need to get a dump to see where these allocations are coming from.

I suppose @carlos-zamora you might also be able to use App Verifier pointed at the Terminal with NVDA turned on. That might catch some of the more obvious mistakes 🤷

@zadjii-msft commented on GitHub (Oct 30, 2023): I'm gonna give @Simon818 another week to try and get back to us here. This sounds really painful, but we need to get a dump to see where these allocations are coming from. I suppose @carlos-zamora you might also be able to use App Verifier pointed at the Terminal with NVDA turned on. That might catch some of the more obvious mistakes 🤷
Author
Owner

@zadjii-msft commented on GitHub (Nov 1, 2023):

I'm gonna close this in favor of #16217, since that thread has more of an investigation in it. Thanks!

/dup #16217

@zadjii-msft commented on GitHub (Nov 1, 2023): I'm gonna close this in favor of #16217, since that thread has more of an investigation in it. Thanks! /dup #16217
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (Nov 1, 2023):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@microsoft-github-policy-service[bot] commented on GitHub (Nov 1, 2023): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report! <!-- Policy app identification https://img.shields.io/static/v1?label=PullRequestIssueManagement. -->
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20710