terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Memory leak

Open PetarPetrushev opened this issue 4 months ago • 8 comments

Windows Terminal version

1.22.12111.0

Windows build number

10.0.26100.4946

Other Software

No response

Steps to reproduce

Enter curl https://s1.cubzyn.net/other/curl.me.php (which curls a large amount of binary to the terminal) And now even if the user closes the terminal window even after the command finished the console window and PTY process uses many gigabytes of RAM and continues to use more until it crashes. I have attached the source code of the PHP script.

curl.me.php

Expected Behavior

Since binary is being sent to terminal some issues are expected such as bells, messed up terminal or messed up input. However not a large memory leak.

Actual Behavior

Terminal freezes when command finishes due to the memory leak and leaks gigabytes of memory in the PTY host process until it crashes.

PetarPetrushev avatar Aug 16 '25 01:08 PetarPetrushev

So, there are a couple places where we cache in-progress VT sequences (SOS, APC, PM, DCS, and OSC); if you spam a bunch of random data you will eventually generate a control sequence introducer and cause us to start buffering...

But also,

... why?

DHowett avatar Aug 20 '25 19:08 DHowett

I have tried this locally with and without the use of curl and could not observe a memory leak myself. Unassigning this issue until someone can reproduce and investigate this.

lhecker avatar Oct 15 '25 15:10 lhecker

Hi. I just retried this and did not experience the memory leak so I think it may have been patched by a different change.

PetarPetrushev avatar Oct 15 '25 16:10 PetarPetrushev

Hi. After doing some more testing this is still and issue and you can reproduce it if you run the command a few more times as the PHP script randomizes the output. I had the issue happen to me after about 5 trys. Try it a few more times as it is random. When it happened this time it froze my PC and i had to reboot.

PetarPetrushev avatar Oct 15 '25 16:10 PetarPetrushev

I've tried it lots and lots of times now and couldn't get it to reproduce.

lhecker avatar Oct 15 '25 16:10 lhecker

I will test it on a new fresh installed VM to see if it occurs. I will attach a video if it.

PetarPetrushev avatar Oct 15 '25 19:10 PetarPetrushev

Actualy im having some issues getting the VM to work however the issue still occurs for me. I am on windows [Version 10.0.26100.6899] terminal: 1.23.12811.0

PetarPetrushev avatar Oct 15 '25 19:10 PetarPetrushev

Hi. After doing some more testing this is still and issue and you can reproduce it if you run the command a few more times as the PHP script randomizes the output. I had the issue happen to me after about 5 trys. Try it a few more times as it is random. When it happened this time it froze my PC and i had to reboot.

I think for reproducible example you can pregenerate 10 files and curl these pregenerated files each. Find that one who do memory leak and update this issue with that uploaded STATIC file instead of .php file, so everyone can reproduce that case.

psnet avatar Nov 07 '25 12:11 psnet