Fix locale for portable results
Plug memory leak

When deciding which buffers to free, there is no need to take
into account output files that have no pending data to write,
apart from the most advanced one, which points to buffered data
that will be reassigned.

This is important when scattering (rather than duplicating) data,
because in this case the output file pointers can diverge by a lot,
and lead to OOM conditions.
Specify a reasonable amount of memory

512M per core seems reasonable.  The default seems too conservative.
Ignore gdb history
Prevent pipe writers from blocking
Verify that input is sorted
Disable input side buffering

This will avoid out of memory conditions.
Ensure sort and merge collation match