intellij-haskell icon indicating copy to clipboard operation
intellij-haskell copied to clipboard

Stack processes seems to leak on Windows

Open ForNeVeR opened this issue 5 years ago • 4 comments
trafficstars

Right now, after a long day of working on my Haskell project in IntelliJ-Haskell (which was immensely helpful, thanks a lot for your work!), I see 27 (!) Stack processes in the background.

A quick PowerShell query I've performed to enumerate them:

$ WMIC PROCESS get Commandline | select-string stack.exe -Raw > T:\Temp\process.txt

I will attach the whole file as-is, but there's one interesting fact: string icfpc-mmxx-codingteam:test:modulator-test occurs 22 times across this file, which means there's 22 Stack processes with this test module in the command line. Is that right? Does the plugin has to keep them all alive?

Most of them keep around 30 MiB of memory, which is… I guess, pretty tolerable these days? But still, I'm not sure all these processes have to be kept around.

Here's the process list: process.txt

UPD: The last process in the list, stack run interactor, was started by me manually; everything else have its roots in the idea.exe process, so, obviously, these're Stack processes started by IntelliJ-Haskell for various purposes.

ForNeVeR avatar Jul 20 '20 16:07 ForNeVeR

Thanks for reporting!

Is that right? Does the plugin has to keep them all alive?

No, that's not intended behavior.

The plugin restarts the test REPL when the user switches from library code to test code. So when something goes wrong during that restart, it's in line with your report.

On macOS and Ubuntu I never noticed this behavior. Could be a specific Windows issue... I will keep an eye on it.

rikvdkleij avatar Jul 20 '20 18:07 rikvdkleij

@ForNeVeR Is this issue still happening?

rikvdkleij avatar Aug 01 '20 10:08 rikvdkleij

I was able to reproduce the issue on 1.0.0-beta78 (the latest one at the moment), and 1.0.0-beta76, too. Steps to reproduce:

  1. Get a fresh Stack installation on Windows (I use choco install haskell-stack for that)
  2. Clone this project: https://github.com/codingteam/icfpc-2020
  3. Wait for the project import to finish (i.e. for all build processes to finish)
  4. Open a file test/Spec.hs, type something
  5. Switch to a branch portnov/evaluator
  6. Open a file test/Spec.hs (again), type something
  7. Switch back to master
  8. Go to step 4

During steps 4–8, you'll see this error popup from time to time: image

After each of these messages (seemingly?), stack process count will raise by two. I was eventually able to get 22 of these processes (quickly counted by (get-process stack).count in pwsh).

ForNeVeR avatar Aug 02 '20 11:08 ForNeVeR

Note that the process tree looks like this: image (first stack.exe is a Chocolatey wrapper I have in Path)

So, when I say that the count has been increased by two, I mean that one additional subtree like this has been spawned (since it incorporates two stack.exe processes).

ForNeVeR avatar Aug 02 '20 11:08 ForNeVeR