I have been using Python's subprocess module to run some processes using subprocess.Popen
. I developed the code on my Mac OS, but now I am running it on Linux server. After memory profiling using resource.getrusage(RUSAGE_SELF).ru_maxrss
of my Parent and child process, I am finding the memory allocation mechanism as entirely different on two platforms.
I have researched everywhere on the differences in the behaviour of fork under Mac and Linux, but nowhere anything like this is mentioned.
I am running a loop like this:
for t in range(1000):
pid = subprocess.Popen([EXECUTABLES, FILNAME])
# execute some commands here
pid.terminate()
pid.wait()
On Mac:
- The child process has constant RSS
- The parent process has increasing RSS
On Linux:
- RSS of child process = RSS of the parent process
- RSS of the parent process is increasing drastically
- Which is making child process to increase drastically