microsoft / microsoft/WSL

Option to reclaim memory even when there are background processes (disowned or nohup)

Open
#7,470 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

Is your feature request related to a problem? Please describe.

I use powerline to customize the shell prompt (it has TMUX integration where others don't).

The tool always have a powerline-daemon process running at the background.

This prevents WSL2 from reclaiming the memory even when I exit all the shell prompts.

> wsl -- ps auxf
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0    900   528 ?        Sl   20:28   0:00 /init
root         8  0.0  0.0    900    84 ?        S    20:28   0:00 /init
tigerin+  1277  3.7  0.4 141228 53112 ?        Sl   20:42   0:00  \_ /usr/bin/python3 /home/tigerinus/.local/bin/powerline-daemon -q
root      1571  0.0  0.0    900    84 ?        Ss   20:42   0:00 /init
root      1572  0.0  0.0    900    84 ?        S    20:42   0:00  \_ /init
tigerin+  1573  0.0  0.0   9668  3300 pts/0    Rs+  20:42   0:00      \_ ps auxf

Describe the solution you'd like

It'd be nice to add an option, such that when there is no active pts session, i.e. shell session, regardless how many headless (i.e. pty-less) processes, WSL2 will proceed and reclaim the memory.

Describe alternatives you've considered

I've tried including a script in .bash_logout such that when this is the last PTY session, call powerline-daemon -k to kill the background process, so later WSL2 will be able to reclaim.

Obviously, this works for this specific process only.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no source files or tests. Start by tracing WSL2's memory-reclaim behavior and how it detects active PTY sessions; done means an option allows reclaiming memory when only headless processes remain, with coverage for active and inactive PTY cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.