Setup fails: Cannot allocate memory

Yes (except one small perl script).

MemFree: 758840 kB

But more than 3 GB is for cache.

The latter without any changes.

db_shared_buffers: "1024MB"
no entry for unicorn_workers
#db_work_mem: "40MB"