WSL icon indicating copy to clipboard operation
WSL copied to clipboard

WSL2 + Docker causes severe memory leaks in vmmem process, consuming all my machine's physical memory

Open davidr-PA opened this issue 4 years ago • 188 comments

Version

Microsoft Windows [Version 10.0.19044.1889]

WSL Version

  • [X] WSL 2
  • [ ] WSL 1

Kernel Version

5.10.102.1

Distro Version

Ubuntu-20.04

Other Software

Docker Desktop: 4.11.1

Repro Steps

You simply need to build docker images several times. It results in this: 2022-08-15 17_36_43 - WSL2_Docker_vmmem - Microsoft​ Edge

Note: I don't even have any active Docker containers running. Everything's terminated.

It seems to be the same as this issue, reported 3 years ago and still unresolved: https://github.com/microsoft/WSL/issues/4166

I never encountered this on MacOS, but it's slowing my development speed down greatly on Windows. It definitely gets worse the more times I build Docker images. It's resulting in build processes slowing down to somewhere between 1/10th and 1/50th the speed they run at when physical memory is available. It makes me need to restart my computer sometimes multiple times per day.

Expected Behavior

Memory gets released after processes terminate.

Actual Behavior

Memory does not get released, resulting in my computer using virtual memory and slowing to a crawl. Resource usage (with no active containers running - all terminated): 2022-08-15 17_36_43 - WSL2_Docker_vmmem - Microsoft​ Edge

Diagnostic Logs

No response

davidr-PA avatar Aug 15 '22 23:08 davidr-PA

I have the same issue only by running a few fixed docker images. Within 2 days the memory is 100% used only stopping Docker Destop releases the memory. So I have switched back to Docker Desktop 4.11.0

labanv avatar Aug 22 '22 19:08 labanv

This is also happening to our team. Seems to have started for us last week. It appears to be maxing out our WSL memory allotted also, as the total calculated processes memory in task manager was not equal the total memory being used.

kkruit avatar Aug 25 '22 16:08 kkruit

Same here on Windows 11 and Docker Desktop 4.11.1. Running asp.net containers from Visual Studio.

Drol avatar Aug 26 '22 11:08 Drol

This is also happening to our team. Seems to have started for us last week. It appears to be maxing out our WSL memory allotted also, as the total calculated processes memory in task manager was not equal the total memory being used.

Same for me. Memory in task manager doesn't add up to total. Limiting the wslconfig file does limit the memory af the task, however, it's like the memory doesn't get returned and after 2-3 days or runtime my computer hits 100% memory usage and I have to reboot.

julestop avatar Aug 26 '22 20:08 julestop

Please fix.

LiamKarlMitchell avatar Aug 28 '22 09:08 LiamKarlMitchell

Also saw this, unsure if was related to unstarted containers - resource monitor showed ~6 instances of vmmem with 1GB committed and 0KB working set (and one or two with both committed and working, looking more functional). Task manager showed 99% RAM used, but no really large consumers (just things like Chrome, JDK, Teams, one functioning(ish, given the RAM usage) vmmem, all in 100s MB).

Also running 4.11.1.

@labanv, did rolling back help you?

chrisb2244 avatar Aug 29 '22 02:08 chrisb2244

Same here on Windows server 2022 and Docker Desktop 4.11.1. After a few days the server memory takes up 100% the total calculated processes memory in task manager was not equal the total memory being used.

Ador-able avatar Aug 29 '22 05:08 Ador-able

Same issue on Windows 10 Docker Desktop v4.11.1. Left my laptop for a bit and came back to 100% memory usage with 16GB and only one image running.

CurtisVermeeren avatar Aug 29 '22 17:08 CurtisVermeeren

This is also happening to our team. Seems to have started for us last week. It appears to be maxing out our WSL memory allotted also, as the total calculated processes memory in task manager was not equal the total memory being used.

Same for me. Memory in task manager doesn't add up to total. Limiting the wslconfig file does limit the memory af the task, however, it's like the memory doesn't get returned and after 2-3 days or runtime my computer hits 100% memory usage and I have to reboot.

Nice, I also limited memory allocation in wslconfig. It helped, but doesn't eliminate the issue (it just allows me to get away with building more docker containers, before my machine starts grinding to a halt as it dips into virtual memory).

davidr-PA avatar Aug 29 '22 19:08 davidr-PA

@labanv, did rolling back help you?

Rolled mine back to 4.10.0 and haven't noticed the issue. So far so good for the last ~24 hours.

JamienAU avatar Aug 30 '22 02:08 JamienAU

@labanv, did rolling back help you?

Rolled mine back to 4.10.0 and haven't noticed the issue. So far so good for the last ~24 hours.

for me it works, memory usage is still increasing (some leaks) but sirtainly not as fast as it would hit 100% in 4.11.1 it must be a combination bug of windows vmmem and docker desktop

labanv avatar Aug 30 '22 16:08 labanv

@labanv, did rolling back help you?

Rolled mine back to 4.10.0 and haven't noticed the issue. So far so good for the last ~24 hours.

Are you back on 4.11.0 or 4.10.0? Looks like you and @labanv are on different versions. I went back to 4.11.0, and seems like my memory still creeps up, maybe more slowly though.

julestop avatar Aug 30 '22 16:08 julestop

@labanv, did rolling back help you?

Rolled mine back to 4.10.0 and haven't noticed the issue. So far so good for the last ~24 hours.

Are you back on 4.11.0 or 4.10.0? Looks like you and @labanv are on different versions. I went back to 4.11.0, and seems like my memory still creeps up, maybe more slowly though.

I'm back at 4.11.0 but as I say it also increases memory usage but slowly.

labanv avatar Aug 30 '22 16:08 labanv

I just rolled back from 4.11.0 to 4.10.0 and rebuilt everything, will report back.

julestop avatar Aug 30 '22 18:08 julestop

Have been monitoring memory usage for 48 h now and it's looking good, RAM usage is at the expected level and hasn't creeped up.

JamienAU avatar Aug 30 '22 21:08 JamienAU

Probably related and it will be fixed soon: https://github.com/docker/for-win/issues/12877

ben186 avatar Aug 31 '22 07:08 ben186

Also duplicates https://github.com/microsoft/WSL/issues/8703

mrgreywater avatar Sep 02 '22 13:09 mrgreywater

Hi mrgreywater,

I have a fresh install of both WSL and Docker 4.12 and this issue still persists.

jonny-circles avatar Sep 26 '22 11:09 jonny-circles

@mrgreywater I re-installed with Docker Desktop 4.12, and I still seem to be encountering memory leaks when I build Docker images. Will continue to test as I will definitely be building more Docker images soon - and I will confirm if I see otherwise - but as of now this appears to still be active.

EDIT: Docker version is:

docker --version
Docker version 20.10.17, build 100c701

davidr-PA avatar Sep 26 '22 20:09 davidr-PA

for me process is based on:

  • stopping docker desktop
  • running wsl --shutdown
  • manually restarting LxssManager service - this frees up all memory
  • starting docker desktop
  • do it again after couple of hours, when memory is again almost full

ivsokol avatar Sep 27 '22 21:09 ivsokol