As Tom mentioned, it sounds like you're being bitten by the oom
killer. If, for some reason, you cannot run with it turned off, then
add a really big swap space so it delays the onset of sudden death by
oom to something really big.
Is It possible your work_mem is set too high?