I tried this (to observe the behaviour of unix sort):
yes | sort & top
What I see is the unix memory usage growing, as you would expect, but the sort process itself's memory does not appear to be growing:
Mem: 1689540k total, 1455384k used, 234156k free, 147248k buffers
Swap: 1718268k total, 804k used, 1717464k free, 956216k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
32248 mgregory 20 0 29844 25m 692 R 95.0 1.6 0:32.98 sort
32247 mgregory 20 0 4036 504 444 S 4.0 0.0 0:01.52 yes
The number 1455348 is growing rapidly
The number 29844 is not growing.
What is happening there?