This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Memory leak subprocess on Windows
Type: resource usage Stage: resolved
Components: Library (Lib), Windows Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: brian.curtin, rfs, terry.reedy, tim.golden, vstinner
Priority: normal Keywords:

Created on 2012-04-17 18:56 by rfs, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (7)
msg158565 - (view) Author: Roland (rfs) Date: 2012-04-17 18:59
subprocess leaks memory on win 7 64bit (Python 2.7.3 32bit).
The following code snippet will fill up memory slowly but completely after running it multiple times. When python exits the memory is not freed.

>>>>>>>>>>

import subprocess
import shlex

for i in range(0, 10000):
    p = subprocess.Popen(shlex.split("ipconfig", posix=False))

    result = p.communicate()

print "end"

<<<<<<<<<<
msg158602 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-04-18 11:16
I don't see any leak on Linux with Python 2.7 or Python 3.3. How much KB does subprocess leak per process?
msg158604 - (view) Author: Roland (rfs) Date: 2012-04-18 11:41
20kb exactly, I can confirm it is only on Windows. I'm currently running some tests to make sure it isn't a general Windows problem. I'll post an update as soon as done.
msg158605 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-04-18 11:48
> 20kb exactly, I can confirm it is only on Windows. I'm currently running some tests to make sure it isn't a general Windows problem. I'll post an update as soon as done.

Oh, that's a lot. Can you please also try with Python 3.2?
msg158627 - (view) Author: Roland (rfs) Date: 2012-04-18 14:44
Yes, ok, my sincere apologies, I should've tested more thoroughly before filing a report here. It seems to be a Windows problem. I could replicate the issue using a batch script (and Python 3.2 for that matter). I'm still in the dark about what it causes, but here's a more detailed problem description for those interested.

http://tinyurl.com/cgbf4u2
msg158870 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-04-20 18:39
Does your last message mean that this issue should be closed here?
msg158914 - (view) Author: Roland (rfs) Date: 2012-04-21 10:41
yes, thank you.
History
Date User Action Args
2022-04-11 14:57:29adminsetgithub: 58811
2012-04-21 10:48:08neologixsetstatus: open -> closed
resolution: not a bug
stage: resolved
2012-04-21 10:41:32rfssetmessages: + msg158914
2012-04-20 18:39:50terry.reedysetnosy: + terry.reedy
messages: + msg158870
2012-04-18 14:44:46rfssetmessages: + msg158627
2012-04-18 11:48:49vstinnersetmessages: + msg158605
2012-04-18 11:41:47rfssetmessages: + msg158604
2012-04-18 11:16:14vstinnersetnosy: + vstinner

messages: + msg158602
title: Memory leak subprocess -> Memory leak subprocess on Windows
2012-04-17 23:37:28pitrousetcomponents: + Library (Lib), Windows
2012-04-17 23:37:20pitrousetnosy: + tim.golden, brian.curtin
2012-04-17 18:59:41rfssetmessages: + msg158565
2012-04-17 18:56:01rfscreate