1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WSL2でのメモリ使用量制限まとめ

Last updated at Posted at 2022-01-09
WSLリリースノートから抜粋
ビルド 20175
WSL2 VM の既定のメモリ割り当てを、ホスト メモリの 50% または 8 GB のどちらか少ない方になるように調整します [GH 4166]。

ビルド 19028
[WSL2] Linux VM に割り当てられた既定のメモリ容量を、ホスト メモリの80% に調整します
Windows10の場合

WSL2がサポートされているリリース版Windows10はビルドが1904x.xxxなので、ホストメモリの80%。

Windows11の場合

Windows11のビルドバージョンは22000.xxxなので50%。ただし、手元で確認したところ、上記リリースノートにあるような8GB制限はかかっていなかった

メモリ使用量制限方法

メモリ使用量は%USERPROFILE%\.wslconfig※に設定を書くことで制限できる。
※ C:\Users\<ユーザー名>\.wslconfig

内容は

%USERPROFILE%.wslconfig(2GBに制限する場合)
[wsl2]
memory=2GB

詳しくは、WSL での詳細設定の構成に記載されているのでそちらを参照。

注意点

Windows標準メモ帳で作成する場合には罠がいくつか、

  1. 保存するときには「ファイルの種類」をすべてのファイルにする。
    単にファイル名を.wsconfigにしただけでは.wslconfig.txtというファイルができる。
    ファイル名が異なると認識されない。
    2022-01-09.png

  2. エンコードに注意。利用できるのはANSI,UTF-8のいずれか。
    それ以外になっていると適用されない。
    この制限はWSL Preview 0.51.0にて解除(2022.01.22追記)
    2022-01-09 (1).png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?