subroutine reads an entire file into memory. Your 'Out of Memory' message might be concerned with that, rather than forks and threads. Although there are a number of places where you fork child processes (date, awk, rm) unnecessarily, I doubt you would get that particular error message. Are the files being read on each machine exactly the same size?
A good move would be to trace when the program is executing when it crashes. If you do that, make sure you print to STDERR (or maybe use
) in case messages are lost through buffering.