Skip to content

Docker process doesn't free up memory - macOS, Apple Silicon, Virtualization.framework #6120

Description

@z1r0-

With Virtualization.framework enabled the Docker process (not Virtual Machine Service) grows in memory-usage and doesn't free it up properly. After some testing I noticed, that it seems to be related to transfers between host and docker-container.
Easiest example: copy a 1GB file using "docker cp" and the memory-usage will grow by 1GB. But happens with other stuff too (like importing a db with local client over a host-bind port).

Example:

dd if=/dev/zero of=output.dat  bs=1m  count=1024
docker run -d --rm --name mem_test alpine tail -f /dev/null
docker cp output.dat mem_test:/tmp/
# Watch Memory grow in Activity Monitor

I've seen the discussion about "Memory" and "Real Mem" in Activity Monitor and first thought "okay, Real Mem returns to normal after some time so it will be fine" but then I noticed, that MacOS starts swapping when "Memory" value gets to big even "Real Mem" is just some MB.

image

image

After restarting Docker (from docker context menu) everything goes back to normal again.. So I'm currently restarting Docker every time memory usage gets to huge.. I've usually 20+GB of free memory and no swap usage if I don't forget to restart Docker, so it's deff it.

I'm using the most recent version: Docker Desktop 4.3.2 (72729) and MacOS 12.2 Beta (but I had same behaviour with 12.0, 12.1).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions