Search code examples
pythonmemory-leakssubprocessplumbum

plumbum leaking Popen objects


I have a daemon-like process which runs commands in subprocesses using plumbum. I noticed it leaks Popen objects.

Easy to reproduce:

from plumbum.cmd import ls
x = [ ls() for i in range(500) ]
del x
import gc
gc.collect()
import objgraph
[ x for x in objgraph.most_common_types(10000) if 'Popen' in str(x) ]
=> [('Popen', 500)]

Is this a bug? (I couldn't find where to report bugs in plumbum...)

I also "experimented" with modifying the leaking Popen objects, trying to break the reference-cycle (assuming one exists, to cause the leak), but it didn't help.

Running on linux, plumbum version 1.14.0.


Solution

  • It's been fixed, aren't you the one who opened that issue?

    issue: https://github.com/tomerfiliba/plumbum/issues/166 commit: https://github.com/tomerfiliba/plumbum/commit/a565720631b210642fb6f2f7e9e6bb59e7e395e1