본문 바로가기

WSL2

WSL2 memory 조정하기 # .configwsl # 리소스 # Vmmem, VmmemWSL

728x90
반응형

WSL2를 설치한 후에 컴퓨터가 이상하게 느려져서 작업관리자를 보니 메모리를 반이나 잡아먹고 있는 놈이 있었습니다.

VmmemWSL 이었는데, 다른 분들은 Vmmem으로 표시되는 경우도 있더군요.

WSL 설치 후에 별다른 설정을 하지 않으면 보통 메모리의 반정도는 default로 차지하는것 같습니다.

 

WSL이 차지하는 memory를 설정해서 기본  Windows 환경을 다시 빠르게 만들어주도록 하겠습니다.

(WSL을 위주로 작업할때는 설정을 WSL이 메모리를 많이 차지 할 수 있도록 하면 되겠죠?)

 

1) .configwsl 파일 생성

wsl을 엽니다.

editor "$(wslpath "C:\Users\YourUsername\.wslconfig")"

 

구체적인 명령어 예시

nano "$(wslpath "C:\Users\taltal\.wslconfig")"

 

에디터가 열리면 원하는 만큼 메모리를 설정(저는 1GB로 했습니다.)

[wsl2]
memory=1GB

잘 저장하고, WSL 창을 닫습니다.

 

 

2) Windows PowerShell을 관리자 권한으로 실행하고 아래 명령어로 wsl을 종료

wsl --shutdown

 

3) 다시 WSL을 실행하고 아래 커맨드로 memory 설정을 확인해봅시다.

free

# 또는

free -h --giga

 

그 외 설정 조정:

[wsl2]
#kernel=<path>              # An absolute Windows path to a custom Linux kernel.
memory=4GB            	    # 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

 

출처:

https://www.aleksandrhovhannisyan.com/blog/limiting-memory-usage-in-wsl-2/#1-create-wslconfig

https://seokbeomkim.github.io/posts/wsl-customize-resource/

 

728x90
반응형