Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Out of Memory" in Docker preview guest on M1 Mac Mini #4485

Closed
spease opened this issue Jan 28, 2021 · 5 comments
Closed

"Out of Memory" in Docker preview guest on M1 Mac Mini #4485

spease opened this issue Jan 28, 2021 · 5 comments
Labels

Comments

@spease
Copy link

spease commented Jan 28, 2021

Describe the bug

All the nix commands I've tried with both the docker LnL7/nix and nixos/nix images fail with out of memory errors using the Docker Preview on an M1 Mac Mini.

EDIT: Note that while my examples show me mounting the CWD to /nixpkgs, this is not necessary to reproduce the bug. Either of these commands will have the same issue without the volume mount:

docker run -it nixos/nix nix-env --version
docker run -it nixos/nix nix eval "(import <nixpkgs> {}).lib.version"
docker run -it lnl7/nix nix eval "(import <nixpkgs> {}).lib.version"
docker run lnl7/nix nix eval "(import <nixpkgs> {}).lib.version"
docker run nixos/nix nix eval "(import <nixpkgs> {}).lib.version"

Steps To Reproduce

Install the current Docker M1 Tech Preview:
https://docs.docker.com/docker-for-mac/apple-m1/
https://desktop.docker.com/mac/m1preview/Docker-AppleSilicon-Preview7.dmg

Execute this command:

docker run -v $(pwd):/nixpkgs -it nixos/nix nix eval "(import <nixpkgs> {}).lib.version"

You'll see:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
GC Warning: Failed to expand heap by 402653184 bytes
GC Warning: Failed to expand heap by 557056 bytes
GC Warning: Failed to expand heap by 294912 bytes
GC Warning: Out of Memory! Heap size: 0 MiB. Returning NULL!
error: out of memory

You can try increasing the memory, but I got the same error up to 6gb.

Expected behavior

"21.03pre266259.2fcf614ea38"

nix-env --version output

$ docker run -v $(pwd):/nixpkgs -m 1gb -it nixos/nix nix-env --version                              ~/Projects/nixpkgs
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
GC Warning: Failed to expand heap by 402653184 bytes
nix-env (Nix) 2.3.10

Additional context

My suspicion is that there is an underlying docker issue, but I still felt it was worth officially documenting it.

@spease spease added the bug label Jan 28, 2021
@spease spease changed the title "GC Warning" with Docker preview on M1 Mac Mini "Out of Memory" in Docker preview guest on M1 Mac Mini Jan 28, 2021
@spease
Copy link
Author

spease commented Jan 28, 2021

May be related to NixOS/nixpkgs#38635 (and sorry if this is in the wrong repo)

@vcunat
Copy link
Member

vcunat commented Jan 28, 2021

No. command time nix eval "(import <nixpkgs> {}).lib.version" reports memory peaking below 40 MB for me. EDIT: the linked issue applies to cases when you evaluate lots of packages to get their names (which isn't considered a "normal usage" nowadays).

@mtiller
Copy link

mtiller commented Mar 20, 2021

I wanted to add that I'm seeing this same issue and it has nothing to do with nix (as far as I can tell). I'm running the OpenModelica compiler included in the mtiller/book-builder docker image and I randomly get the following errors:

GC Warning: Failed to expand heap by 11137024 bytes
GC Warning: Failed to expand heap by 262144 bytes
GC Warning: Out of Memory! Heap size: 31 MiB. Returning NULL!

But if I run the command again, it (generally) succeeds (i.e., this is not deterministic behavior...which is frustrating but also suggestive of a bug). This only happens when I use this Docker image on my M1 Mac. As with the OP, I also tried increasing memory, but this isn't an issue with how much memory is available. I can watch the system with top and these processes take almost no memory (max I've seen is 4% of system memory).

@mtiller
Copy link

mtiller commented Mar 20, 2021

I should add that I'm running a Docker Desktop version that reports itself as being 3.3.0 (62069).

@domenkozar
Copy link
Member

Seems to be a docker issue: docker/for-mac#5204

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants