My bad, it's not ulimit -n 1000000 (but you probably still need that line, it's for the maximum number of files that can be opened at a time) but ulimit -s $(ulimit -Hs) which increases the stack size