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 on package installation #421

Closed
Zert opened this issue Dec 18, 2014 · 11 comments
Closed

Out of memory on package installation #421

Zert opened this issue Dec 18, 2014 · 11 comments

Comments

@Zert
Copy link

Zert commented Dec 18, 2014

Sometimes on nix-env -i pkgname I have such error:

  error: unable to fork: Cannot allocate memory

There is 1Gb RAM on VirtualBox instance. Is 1Gb memory amount not enough for nix? Any plans to reduce a memory consumption?

@vcunat
Copy link
Member

vcunat commented Dec 18, 2014

The evaluation can be expensive, especially for nix-env without -A, as it has to evaluate all packages and check their names.

@Zert
Copy link
Author

Zert commented Dec 18, 2014

NixOS now has about 3500 packages, while Gentoo has about 20000. So, when NixOS will have such amount of packages, will it consume 6 GB memory?

@7c6f434c
Copy link
Member

No, everyone will just use -iA from the very beginning…

@domenkozar
Copy link
Member

NixOS has ~14k packages. And yes, it's memory intensive. As said, we're aiming for -iA to be preferred way of installing software.

@Zert
Copy link
Author

Zert commented Dec 18, 2014

What is destiny of such functionality if nobody uses it? First you made evaluation of all packages, then you do not use it. Nice 😎

@7c6f434c
Copy link
Member

Currently the package attribute names slowly converge to their package names; initially Nix language didn't allow attributes named foo-bar

@edolstra
Copy link
Member

You can tell Nix to garbage-collect more aggressively:

GC_INITIAL_HEAP_SIZE=128k nix-env -qa

With this, nix-env -qa takes 235 MB on my laptop. (Without it, 471 MB.)

You can also do:

echo 1 > /proc/sys/vm/overcommit_memory

That should make the fork error go away.

@Zert
Copy link
Author

Zert commented Dec 18, 2014

@edolstra GC_INITIAL_HEAP_SIZE=128k had no effect, but echo 1 > /proc/sys/vm/overcommit_memory works fine. Thank you!

@jagajaga
Copy link
Member

I think we should close this issue or wait when nix won't use such amount of memory.

@jagajaga
Copy link
Member

Because I have the same problem on 1GB of memory.

@akavel
Copy link

akavel commented Mar 24, 2017

As a note for future readers: this happended for me on Hyper-V too, and the suggested overcommit_memory tweak fixed it for me. I assume a change like below in /etc/nixos/configuration.nix should have the same effect:

boot.kernel.sysctl."vm.overcommit_memory" = "1";

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

No branches or pull requests

7 participants