in reply to Memory Leak Advice

If that’s all what you are doing, which is not quite complex, I don’t see much chance for memory leak, with a reasonable coding style.

How do you copy the files? My guess is that you started some child process each loop(?), and didn’t waitpid() them, thus created the possibility of using up resources. This is a common error. Pure guess, as didn't see your code