# echo foo | sort
sort: memory exhausted
I can't reproduce this on any machine.
Are you sure it's not just what it says, out of memory?
It turns out that the bug is the usage of
which returns a number which may not be available to a single
process on a 32bit system with 4GB RAM. In my case,
it returns 3.8GB. It is the total free memory on my machine.
But it is the usable memory for a single process.
I am using a patch like this. It seems to work on my 4GB machine.
--- textutils-2.0.11/src/sort.c.mem Sat Feb 3 13:31:56 2001
+++ textutils-2.0.11/src/sort.c Sat Feb 3 13:35:59 2001
@@ -630,7 +630,9 @@ default_sort_size (void)
/* Set sortalloc to 50% of available memory, unless it overflows. */
double mem = physmem_available ();
- sortalloc = min (mem, SIZE_MAX);
+ /* Roughly, we may not use more than 1/3 of the adddress space in
+ a single process on Linux even if more memory is available. */
+ sortalloc = min (mem, SIZE_MAX / 3);
sortalloc >>= 1;
if (sortalloc < SORTALLOC_DEFAULT_MIN)
This defect is considered MUST-FIX for Florence Release-Candidate #1
Should be fixed in textutils-2.0.11-4. Thanks for the patch!