Lxc import uses too much RAM

I have had this issue for a while, so I think it is best to report it.

I have a export of a container that is not that big:

stanislas@xps ~> ll notthatbigct.tar.gz
.rw-r--r-- 3,5G stanislas wheel 29 janv. 14:04 notthatbigct.tar.gz

When I import it, it uses an enourmous amount of RAM (more than 10 GB), causing my computer to freeze a bit:

Then it fails:

stanislas@xps ~> lxc import notthatbigct.tar.gz
Importing container: 100% (821.38MB/s)Error: Post http://unix.socket/1.0/containers: EOF

This is an Arch Linux container on Arch Linux, but I had this problem a few months ago on an Ubuntu CT on Ubuntu. LXD is installed from snap.

Could you file a bug at https://github.com/lxc/lxd/issues?

Done: https://github.com/lxc/lxd/issues/5447

I have noticed that the LXD daemon is restarting during the import, probably because of memory usage (no OOM kill though), and thus causing the EOF on the POST request.

I’m happy to report that https://github.com/lxc/lxd/commit/f18362015da4fe468305a12036a7b624206b9ebe fixes this issue, and as of 3.10 the RAM usage is much lower!