Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

"Microsoft Windows Subsystem for Linux Background Host" / "Vmmem"을 종료하는 방법

특정 포트를 점유하고 있는 프로세스를 찾는데,

C:\temp> netstat -ano | findstr 8000
  TCP    127.0.0.1:8000         0.0.0.0:0              LISTENING       17396

pid == 17396이라고 나옵니다. 작업 관리자에서 확인해 봤더니 바로 그 프로세스가 "Microsoft Windows Subsystem for Linux Background Host"였습니다. 이걸 종료하고 싶다면, 현재 해당 프로세스에 연결된 WSL 인스턴스를 종료시켜야 합니다.

그런데, 사실 현재 띄워놓은 WSL 인스턴스가 없는데도 저게 실행 중이라는 것이 문제인데요, 이것을 확실하게 하기 위해서는 wsl.exe 명령어를 활용해야 합니다.

C:\Windows\System32> wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu20.04            Running         2
  docker-desktop-data    Stopped         2
  docker-desktop         Stopped         2

분명히 "Running" 중이군요. ^^ 따라서 다음과 같은 명령어로 해당 인스턴스를 종료해 주면 됩니다.

/*
    --shutdown
        Immediately terminates all running distributions and the WSL 2 lightweight utility virtual machine.

    --terminate, -t <Distro>
        Terminates the specified distribution.
*/

c:\temp> wsl -t Ubuntu20.04

실행 후 곧바로 종료하지는 않으므로 약간의 시간 동안 기다려야 합니다. 아마도 wsl 인스턴스의 재실행 부하를 최소화하기 위해 어느 정도의 대기 시간을 두는 듯합니다.

참고로, (hyper-v vm을 띄우지 않은 경우) 위와 같이 하면 WSL 인스턴스가 사용하던 Vmmem 프로세스도 함께 종료됩니다. 만약 그래도 살아 있다면 WSL 2와 통합시킨 docker desktop을 사용하고 있기 때문일 것입니다. 따라서 docker desktop을 종료시키면 "docker-desktop", "docker-desktop-data"도 함께 종료되면서 Vmmem 프로세스도 내려갑니다.

그나저나, Vmmem 프로세스의 CPU 활동량이 많을 수 있는데요, 만약 docker가 필요하지 않다면 docker-desktop 서비스를 종료해 두는 것이 좋습니다. (WSL 인스턴스 자체로는 보통 CPU 활동량이 많지 않습니다.) 또한 Vmmem 프로세스의 메모리는 윈도우 측의 %USERPROFILE%\.wslconfig 파일을 만들어 다음의 내용을 포함시키면 제한할 수 있습니다.

# WSL commands and launch configurations
# https://learn.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfig

# Taking Back Memory From Vmmem/WSL
# https://blog.simonpeterdebbarma.com/2020-04-memory-and-wsl/

[wsl2]
memory=4GB

# kernel=<path>              # An absolute Windows path to a custom Linux kernel.
# memory=<size>              # How much memory to assign to the WSL2 VM.
# processors=<number>        # How many processors to assign to the WSL2 VM.
# swap=<size>                # How much swap space to add to the WSL2 VM. 0 for no swap file.
# swapFile=<path>            # An absolute Windows path to the swap vhd.
# localhostForwarding=<bool> # Boolean specifying if ports bound to wildcard or localhost in the WSL2 VM should be connectable from the host via localhost:port (default true).

# <path> entries must be absolute Windows paths with escaped backslashes, for example C:\\Users\\Ben\\kernel
# <size> entries must be size followed by unit, for example 8GB or 512MB




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 4/13/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  5  6  7  8  9  10  11  12  [13]  14  15  ...
NoWriterDateCnt.TitleFile(s)
13297정성태3/26/20234354Windows: 235. Win32 - Code Modal과 UI Modal
13296정성태3/25/20233693Windows: 234. IsDialogMessage와 협업하는 WM_GETDLGCODE Win32 메시지 [1]파일 다운로드1
13295정성태3/24/20233958Windows: 233. Win32 - modeless 대화창을 modal처럼 동작하게 만드는 방법파일 다운로드1
13294정성태3/22/20234129.NET Framework: 2105. LargeAddressAware 옵션이 적용된 닷넷 32비트 프로세스의 가용 메모리 - 두 번째
13293정성태3/22/20234197오류 유형: 853. dumpbin - warning LNK4048: Invalid format file; ignored
13292정성태3/21/20234327Windows: 232. C/C++ - 일반 창에도 사용 가능한 IsDialogMessage파일 다운로드1
13291정성태3/20/20234739.NET Framework: 2104. C# Windows Forms - WndProc 재정의와 IMessageFilter 사용 시의 차이점
13290정성태3/19/20234244.NET Framework: 2103. C# - 윈도우에서 기본 제공하는 FindText 대화창 사용법파일 다운로드1
13289정성태3/18/20233437Windows: 231. Win32 - 대화창 템플릿의 2진 리소스를 읽어들여 자식 윈도우를 생성하는 방법파일 다운로드1
13288정성태3/17/20233550Windows: 230. Win32 - 대화창의 DLU 단위를 pixel로 변경하는 방법파일 다운로드1
13287정성태3/16/20233706Windows: 229. Win32 - 대화창 템플릿의 2진 리소스를 읽어들여 윈도우를 직접 띄우는 방법파일 다운로드1
13286정성태3/15/20234163Windows: 228. Win32 - 리소스에 포함된 대화창 Template의 2진 코드 해석 방법
13285정성태3/14/20233755Windows: 227. Win32 C/C++ - Dialog Procedure를 재정의하는 방법파일 다운로드1
13284정성태3/13/20233955Windows: 226. Win32 C/C++ - Dialog에서 값을 반환하는 방법파일 다운로드1
13283정성태3/12/20233496오류 유형: 852. 파이썬 - TypeError: coercing to Unicode: need string or buffer, NoneType found
13282정성태3/12/20233819Linux: 58. WSL - nohup 옵션이 필요한 경우
13281정성태3/12/20233721Windows: 225. 윈도우 바탕화면의 아이콘들이 넓게 퍼지는 경우 [2]
13280정성태3/9/20234477개발 환경 구성: 670. WSL 2에서 호스팅 중인 TCP 서버를 외부에서 접근하는 방법
13279정성태3/9/20234014오류 유형: 851. 파이썬 ModuleNotFoundError: No module named '_cffi_backend'
13278정성태3/8/20233975개발 환경 구성: 669. WSL 2의 (init이 아닌) systemd 지원 [1]
13277정성태3/6/20234637개발 환경 구성: 668. 코드 사인용 인증서 신청 및 적용 방법(예: Digicert)
13276정성태3/5/20234318.NET Framework: 2102. C# 11 - ref struct/ref field를 위해 새롭게 도입된 scoped 예약어
13275정성태3/3/20234676.NET Framework: 2101. C# 11의 ref 필드 설명
13274정성태3/2/20234260.NET Framework: 2100. C# - ref 필드로 ref struct 타입을 허용하지 않는 이유
13273정성태2/28/20233958.NET Framework: 2099. C# - 관리 포인터로서의 ref 예약어 의미
13272정성태2/27/20234218오류 유형: 850. SSMS - mdf 파일을 Attach 시킬 때 Operating system error 5: "5(Access is denied.)" 에러
1  2  3  4  5  6  7  8  9  10  11  12  [13]  14  15  ...