This simple batch file in relatively short order consumes all available memory on Windows 7 (x64). What's going on? and what precautions can be taken to ward against it?
any-invalid-command-you-like-here ^
Apparently necessary preconditions to exhibit the effect:
- the caret
^
is the very last thing in the file, and the script is not terminated with a newline - the caret is preceded by at least 2 spaces or characters, e.g. if the dots in the following represent spaces the memory leak will not be triggered
.^
, while this one will..^
(just slowly)
In this Process Explorer screen shot, the script had been running about 30 seconds, consumed 2.9GB, and was still climbing at a steady rate:
If you're going to experiment with this, make sure you can get at the Close Window [X] control or have a Task Manager or Process Explorer fired up and ready as Ctrl-C, Ctrl-Break, Alt-F4 have no effect.
It appears multiple carets will cause the memory usage to ramp up much more quickly. The first time I encountered this there wasn't enough memory available in 1 or 2 minutes to do simple things like Alt-Tab and even the 3 finger salute Ctrl-Alt-Del was ineffective. I had to hard power off the machine.