Closed jimmyzzzzzzz closed 7 years ago
I assume this is for stress testing purposes?
Each run
opens 2 Pipe
s (for stdout and stderror), and each of those has 2 FileHandle
s. I assume this is where the open files come from. To test this, try using runAndPrint
instead, it uses your application's own stdout and stderror.
Even so, I don't think the files should be kept open after the output from run
has been discarded. I'm on Easter vacation for 1,5 weeks now, but I'll take a look at it when I get back.
After more investigation on this issue recently, the memory leak seems to be inevitable. Even if I create a simple Process without a Pipe and set its stdin, stdout and stderr to nil, it still leaks after its termination. The problem seems to be related to apple's own Process Api. However the open files can be fixed by closing all file handles after process terminates and it resolves the main source of memory leaks in my case.
Thanks, I'll look into having swiftshell close all file handles manually after a Process finishes.
In a new project, I'm using a command line tool project. I'm using source code in my project
It will crash at around 2000th iteration on my machine because the OS cannot open more files. During its execution, the memory increased from 5MB to 50MB and it had more than 6000 open files before crashing. Can anyone reproduce this? or am I using it incorrectly?