121

I'm running docker desktop community 2.1.0.3 on MacOS Mojave. I've got 8GB of memory allocated to Docker, which already seems like a lot (that's half my RAM). Somehow even after exiting and then starting Docker for Mac again, which means no containers are running, docker is already exceeding the memory allocation by 1GB.

What is expected memory usage for docker with no containers running? Is there a memory leak in docker for mac or docker's hyperkit?

enter image description here

docker for mac memory leak

7
  • 2
    I see this on my local system FWIW, but I can right-click on the column header and also enable “Real Memory” and “Compressed Memory” columns. I suspect this column is over-counting virtual memory the process has made space for, but not actually requested real memory.
    – David Maze
    Oct 9, 2019 at 16:53
  • 6
    In github.com/docker/for-mac/issues/3232 there is a link to the following document: Understanding memory usage in Docker Desktop on Mac which also mentions checking the "Real Memory". There are multiple experimentations with some nice details in there. 👍
    – GabLeRoux
    Jan 24, 2020 at 15:30
  • 1
    Docker also use %50 cpu on my macbook pro...
    – fuat
    Apr 11, 2020 at 13:44
  • 2
    my cpu usage is 160% .My system mac os catalina 10.15.5, docker version 2.3.0.3 stable. my computer fan went crazy Jun 7, 2020 at 11:37
  • 1
    my mac also does exactly what @melihsahin described.
    – Thayz
    Jul 9, 2020 at 9:13

3 Answers 3

98

As @GabLeRoux has shared in a comment, the "Real Memory" usage is much lower than what you see in the "Memory" column in Activity Monitor.

This document thoroughly explains memory usage on Mac OS with Docker Desktop and information is excerpted from there.

To see the "Real Memory" used by Docker, right-click the column names in Activity Monitor and Select "Real Memory". The value in this column is what's currently physically allocated to com.docker.hyperkit.

enter image description here

11
  • 22
    In my case hyperkit takes up 14.26GB of memory and 114MB of real memory. kernel_task takes up 11.44GB of real memory. When I stop hyperkit, kernel_task drops to 7.8GB Jul 13, 2020 at 5:35
  • 4
    Ok. What's the solution to the issue ? If starting docker hangs system, apps freeze. Stopping docker works fine. Yes there are memory differences in the activity monitor interface. All I see is com.docker.hyperkit value is huge
    – devansvd
    Jan 9, 2021 at 7:10
  • 14
    So the answer is "don't worry about it"?
    – MikeSchem
    May 4, 2021 at 16:34
  • 27
    My fan is still spinning like crazy and my laptop is much slower even.
    – yudhiesh
    May 5, 2021 at 14:39
  • 3
    If the real memory consumed by hyperkit is significantly lower than the allocated memory, you can configure Docker Desktop to use an amount much closer to the real memory used.
    – yair
    Jun 20, 2021 at 12:51
37

Alternate answer: I reduced the number of CPUs and Memory Docker is allowed to use within the Docker Resources preferences. My computer is running faster and quieter now.

I just now put this in place, so time will tell if this solution works for me. Before it was making my computer max out on memory. Now it's significantly reduced.

Thank you for the note on real memory. I added that to my Activity Monitor.

UPDATE: It's been a few days now and my computer runs well below the max of memory and my fan runs at a minimum if at all.

Docker resources

Mac memory activity

Mac memory usage

3
  • 7
    This is what i was looking for really. My computer has now landed back on earth thank you!
    – Ransom
    Apr 15, 2022 at 19:55
  • 3
    I don't know why people say Docker is better than VirtualBox when it comes to resources... these are the same kinds of settings in VirtualBox... limiting them has the same effect.
    – SteveExdia
    May 2, 2022 at 0:56
  • 1
    This is a limit of Mac, having to spin up a virtual machine instead of running docker natively, with minimal memory usage.
    – Alex R
    Aug 17, 2022 at 9:57
2

I think you shouldn't be using swap while ram is not full, for ssd health and speed

1
  • 2
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Apr 27, 2022 at 1:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.