1

Im having a conundrum with a script (or possible wsl2 memory leak).

I'm running a large script (that takes 0.67 seconds to loop)

My issue is that the loop time is slowly increasing, and so is the memory usage, so from 0.67 seconds / 0.9gig memory to 1.20 seconds / 1.7gig after a few hours.

If I restart (stop/start), the speed goes up again and the memory usage goes down to 0.9 again..

I'm suspecting that my script is leaving running subshells, and I'm wondering if there's anyway to see how many subshells that's currently running?

oh, I'm running this on win10 Wsl2 Ubuntu

1 Answers1

1

Run ps and show only parent process ids and process ids. Pipe the output to awk, setting a variable pid to a given parent process id. Where the first space delimited field (parent process id) is equal to the passed pid, print the process id (field 2)

ps -eo ppid,pid | awk -v pid=<pid> '$1==pid { print $2 }'
Raman Sailopal
  • 12,320
  • 2
  • 11
  • 18
  • I didn't completely understand all that (nothing actually), but if I'm replacing pid with the pid of the running script, what is supposed to be displayed? all subshells that's being created by the script (the pid I wrote) ? – Adam Larsson Dec 24 '20 at 10:26
  • Yeah. Just the child (sub process) ids associated with the passed parent process id (pid) – Raman Sailopal Dec 24 '20 at 10:30