I am unsure about this, but this question might be related to Memory leak in batch for loop?.
I have the following trivial batch script:
@echo off
:label
cmd.exe /c cls
echo hello
goto label
When this script runs on a Windows7 32-bit installation, it behaves well. But when I run it on the few Windows7 64-bit machines that I have access to, it slowly and apparently irrevocably eats up all system memory - as seen in the Windows task manager. The memory stays in use after closing the window that executes the above batch lines.
Is this happening to other people? If not, do you know what could cause this? Other installed software on the system?
I have the same behavior if I do a
while True: os.system('cls')
loop in a Python-X/Y shell. It seems to be linked to the creation of a sub process. If I change the above from cmd.exe /c cls
to just cls
, I do not get a memory leak. I ran into this problem because I ported a Python script from Linux that repeatedly does a clear screen for a statistics display, implemented for Windows as shown in Clear the screen in python.