moby: Windows Containers memory leak

Description

We use Windows Containers for our CI and we have builds running quite frequently one after another.

With every such run, Paged Pool grows infinitely until it exceeds all the available virtual memory of the system. Even if the builds are not running and the docker engine is stopped, the Paged Pool memory won’t go down in time.

Poolmon utility in combination with strings.exe show the following drivers allocating the most of the Paged Pool memory: ntfs.sys, bindflt.sys, fltMgr.sys

Steps to reproduce the issue:

  1. Create a Windows 1809 machine with docker 18.09.2 installed
  2. Run the following Powershell commands:
git clone https://github.com/angular/angular.git
cd .\angular\
git checkout 50c4ec66871aa7aa24d92f5
docker build -f .\.codefresh\Dockerfile.win-1809 --build-arg node_version=10.13.0 --build-arg yarn_version=1.13.0 -t node-bazel-windows .\.codefresh\
while ($true) { docker run --rm -u ContainerAdministrator -v ${pwd}:C:/test -w C:/test --entrypoint cmd node-bazel-windows /s /c 'yarn install --frozen-lockfile --non-interactive --network-timeout 100000 --no-progress & copy .codefresh\bazel.rc %ProgramData%\bazel.bazelrc & yarn bazel test --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only,-browser:chromium-local //... & yarn bazel test --define=compile=aot --build_tag_filters=-no-ivy-aot,-fixme-ivy-aot --test_tag_filters=-no-ivy-aot,-fixme-ivy-aot,-browser:chromium-local //...' }
  1. Observe the tests running in the loop and see the Paged Pool memory growing.

Describe the results you received:

Paged Pool grows infinitely until it exceeds all the available virtual memory of the system

Describe the results you expected:

Paged Pool doesn’t grow infinitely

Additional information you deem important (e.g. issue happens only occasionally):

The issue is reproducible with 1903 and docker 18.09.6 as well and not only with this project code. We tried this with a few Node.js projects using yarn and got the same result.

Output of docker version:

Client:
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.6
 Git commit:        1ac774dfdd
 Built:             unknown-buildtime
 OS/Arch:           windows/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.24)
  Go version:       go1.10.6
  Git commit:       1ac774dfdd
  Built:            02/10/2019 04:13:25
  OS/Arch:          windows/amd64
  Experimental:     false

Output of docker info:

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 332
Server Version: 18.09.2
Storage Driver: windowsfilter
 Windows:
Logging Driver: json-file
Plugins:
 Volume: local
 Network: ics l2bridge l2tunnel nat null overlay transparent
 Log: awslogs etwlogs fluentd gelf json-file local logentries splunk syslog
Swarm: inactive
Default Isolation: process
Kernel Version: 10.0 17763 (17763.1.amd64fre.rs5_release.180914-1434)
Operating System: Windows Server 2019 Datacenter Version 1809 (OS Build 17763.316)
OSType: windows
Architecture: x86_64
CPUs: 16
Total Memory: 62.54GiB
Name: EC2AMAZ-JGQFRJ4
ID: 2WJ3:3ZQC:Y53M:YH2T:6S3G:XS5B:K6DQ:JRGL:YXIK:7LOA:U4W5:BTRK
Docker Root Dir: D:\
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.):

The issue has been reproduced on AWS instances and on Azure VMs

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

@andyfisher100 could you post your comment in https://github.com/moby/moby/issues/42487 as well (if that’s indeed the same issue)?

For what it’s worth, I had a support ticket open with Microsoft for a while but eventually the issue was solved. Some things for people to try

Make sure you use the latest version of docker (24.0.x). instructions can be found here https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/set-up-environment?tabs=dockerce#windows-server-1 Note: Docker enterprise (EE) now requires a license from miranrtis. If you don’t have a license you should installed CE/Moby

Obviously make sure you OS is patched with the latest windows updates

One thing I did notice before installing the windows update that fixed my issue was we had 2 machines that did not have a memory leak. I recently realised that these 2 machines had a page file configured on the drive where we ran docker from (using D: drive whilst OS is on C:). All of the other machines that shown the memory leak, at the time, did not have a page file configured on the docker drive

There is not much more content here but this is a linked item I raised. Most of the content around the issue was internal between our company and Microsoft as we have a support contract https://github.com/microsoft/Windows-Containers/issues/337

@thaJeztah I am still having trouble with memory leaks in a similar scenario (CI/CD). I am using version 19041 run short-lived containers (process isolation) and seeing a gradual increase in the Memory Pool Nonpages Bytes. In about 3 days, it’s jumped 7.5 GB. I am also using the latest Docker engine (Install-Package Docker -ProviderName DockerMsftProvider -RequiredVersion 20.10.4 -Force)