Error report: snapcraft fails on host with 1 GiB of memory

Launching a VM.
launch failed: qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory

An error occurred when trying to launch the instance with 'multipass': returned exit code 2.
Ensure that 'multipass' is setup correctly and try again.

The host was running Ubuntu 18.04.2 and free showed that it had 700+ megabytes available.

  1. Given that the host Ubuntu was not taking up much memory, I would expect that the VM snapcraft created (which is also Ubuntu, right?) should be fine as well.
  2. After a brief search, I could not find any guidance on how to troubleshoot this error. Is it possible to configure multipass or qemu to use less memory?
1 Like

Checkout the SNAPCRAFT_BUILD_ENVIRONMENT_MEMORY environment variable:

by default it allocates 2GiB (the documentation is wrong but I currently can’t fix it)

One of the downside of a VM build is that it will always allocate all memory even if the guest OS isn’t use much. You might want to try building it in an LXD container instead.


That does the trick. Thank you.

1 Like

Perfect. Thank you :+1:

Resolve snapcraft virtual memory exhausted

You can bump up the VM’s memory to 4GB with:

snapcraft clean # Rebuild VM
snapcraft --debug