0

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:

  1. The child process has constant RSS
  2. The parent process has increasing RSS

On Linux:

  1. RSS of child process = RSS of the parent process
  2. RSS of the parent process is increasing drastically
  3. Which is making child process to increase drastically
pg2455
  • 5,039
  • 14
  • 51
  • 78
  • 1
    [Memory allocated to Python is not released back in Linux even after gc.collect()](https://stackoverflow.com/q/5975255/608639), [Will malloc implementations return free-ed memory back to the system?](https://stackoverflow.com/q/2215259/608639), [Memory not freed after calling free()](https://stackoverflow.com/q/5365996/608639), etc. – jww Feb 15 '18 at 14:16
  • Somehow those links are not related to the memory allocation during fork process – pg2455 Feb 15 '18 at 16:28

0 Answers0