hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Memory leak useConpty: true

Open skm7463 opened this issue 5 years ago • 4 comments

  • [x] Version is 3.1.4
  • [x] Does not seem to be a duplicate
  • ** Issue is reproducible without any plugins

Issue

Start powershell.exe (not using Hyper) Enter command:
[System.IO.Directory]::GetFiles("\.\pipe\", "conpty") (This should not produce anything)

Start hyper. In the powershell.exe terminal repeat the command. (This should now result in something like...) \.\pipe\conpty-3699378.300112908-in \.\pipe\conpty-3699378.300112908-out

These are the in/out pipes used by conPty.

Back to Hyper... Split the terminal (any direction) In the powershell.exe terminal repeat the command again. (This should result in something like...) \.\pipe\conpty-3699378.300112908-in \.\pipe\conpty-3699378.300112908-out \.\pipe\conpty-9116907.052751396-in \.\pipe\conpty-9116907.052751396-out

Back to Hyper... Close the split pane. In the powershell.exe terminal repeat the command one last time. (This should result in something like...) \.\pipe\conpty-3699378.300112908-in \.\pipe\conpty-3699378.300112908-out \.\pipe\conpty-9116907.052751396-in \.\pipe\conpty-9116907.052751396-out

...so the last two pipes have remained open. This leads to a leak (unfreed resources).

If you repeat this enough times, you'll reach an open file limit of Windows (granted, maybe 8000+ of them).

Attached is an automated test (index.js) that opens and closes a split pane repeatedly. The left open pipes can be seen with powershell as above while it runs.

Additional notes

With useConpty: false, repeat the test but use the command: [System.IO.Directory]::GetFiles("\.\pipe\", "winpty")

You'll see winpyt pipes are closed properly.

index.txt hyper-true.txt hyper-false.txt

skm7463 avatar Oct 18 '21 22:10 skm7463

Seems to be coming from node-pty upstream https://github.com/microsoft/node-pty/issues/471

LabhanshAgrawal avatar Oct 21 '21 16:10 LabhanshAgrawal

Yes I noticed this during testing. I was wondering if there is an updated node-pty you could move to that maybe fixes it.

skm7463 avatar Oct 21 '21 16:10 skm7463

we're on the latest build I think

LabhanshAgrawal avatar Oct 21 '21 16:10 LabhanshAgrawal

ah ok, thanks

skm7463 avatar Oct 21 '21 16:10 skm7463