Topic clusters
Docker and Ollama still using memory after you close them
Docker Desktop keeps a virtual machine running, and Ollama keeps a model in memory for minutes after the last request. Closing the window frees neither. Here are the commands that do.
Two tools surprise Mac developers with memory they did not expect to still be in use. Docker Desktop runs your containers inside a virtual machine that holds the memory you allowed it, whether or not any container is busy. Ollama loads a model into memory when you first use it and keeps it there for a few minutes afterwards so the next request is fast.
Neither is a bug. Both are trade-offs you can adjust. This guide shows what each one holds right now and how to give memory back without losing anything.
Ollama: see and unload the loaded model
The Ollama menu bar app and its background server stay running when you close the chat window. The server loads a model on the first request and, by default, keeps it in memory for 5 minutes after the last one. A large model can hold many gigabytes in that time.
ollama psAn empty list means nothing is loaded. The UNTIL column shows when Ollama will unload the model by itself.
ollama stop llama3.2This frees the model's memory immediately. The next request loads it again, which takes a few seconds.
OLLAMA_KEEP_ALIVE=1m ollama serveThe default is 5m. If you start Ollama from the menu bar app instead, set the variable with launchctl setenv OLLAMA_KEEP_ALIVE 1m and restart the app.
Docker Desktop: what the virtual machine holds
Docker Desktop on a Mac runs Linux in a virtual machine, and macOS sees it as one large process. The memory limit you set under Settings > Resources is a ceiling for that machine, and the machine takes what it needs up to the ceiling. Containers you have stopped do not hold memory, but the machine itself stays up while Docker Desktop is open.
docker stats --no-streamIf this prints Cannot connect to the Docker daemon, Docker Desktop is not running and is holding no memory.
docker stop $(docker ps -q)docker system dfGive Docker's memory back
Quitting Docker Desktop from its menu bar icon (Quit Docker Desktop) stops the virtual machine and returns its memory. Closing the dashboard window does not. If you start Docker every day but use it for a few hours, quit it when you finish.
If you leave it running, lower the memory limit in Settings > Resources to what your containers need, and consider turning on Resource Saver mode in recent versions, which pauses the machine when no containers are running. Check docker stats while your normal stack is up to see how much it uses.
Docker's disk use is a different problem
Docker Desktop stores its images and volumes in one disk image, Docker.raw, in ~/Library/Containers/com.docker.docker/Data/vms/0/data. It is a sparse file: Finder and ls show its maximum size, which can be far larger than what it really uses. Use du -sh to see the real figure. It counts toward System Data in Storage settings, which is covered in why System Data is so large.
du -sh ~/Library/Containers/com.docker.docker/Data/vms/0/dataWhy the memory does not feel free afterwards
macOS does not hand freed memory straight to another app; it keeps it as cache until something needs it. So the useful check is memory pressure and swap, not the free number. After unloading a model or quitting Docker, run sysctl vm.swapusage and watch whether swap stops growing. Swap already written to disk is only read back when needed.
Questions
Why is Ollama still using memory when I am not using it?
Ollama keeps a model loaded for 5 minutes after the last request by default, so the next one is fast. Run ollama ps to see what is loaded and ollama stop <model> to unload it now.
How do I unload an Ollama model from memory?
Run ollama stop followed by the model name shown by ollama ps. The memory is released immediately and the model loads again on the next request.
Does closing the Docker Desktop window free memory?
No. The virtual machine keeps running while Docker Desktop is open. Use Quit Docker Desktop from the menu bar icon to stop it and return its memory.
How do I limit how much memory Docker uses on a Mac?
Open Docker Desktop, go to Settings > Resources and lower the memory limit. Use docker stats --no-stream with your usual containers running to see what you actually need.
Why does Docker.raw look so large in Finder?
It is a sparse disk image. Finder shows its maximum size, not what it really occupies. du -sh on the folder shows the space it actually uses.