If you get this error you may assume it is a lack of memory, which it could be, but more likely it is the default memory size of 256M. The file in this example was about 350M big which of course exceeds the virtual memory limits.
This makes sense in smaller mail servers but if you have large amounts of users or e-mails this limit should be bumped.
Check your default size limit:
doveconf -n | grep -E 'vsz_limit|service imap'
default_vsz_limi........