Memory leak
Posted: 07 Jan 2010 06:47
Hi,
I'm experiencing a memory leak while running a batch file.
The file consists of a loop, which runs every 30s. Every time the loop runs, it increases the memory requirement by about 1MB.
The memory is not released once the batch is finished, and doesn't show up anywhere else in the task manager. It's simply gone.
That adds up to about 3Gb a day, forcing me to restart the computer eversday. Doesn't sound like much, but I have calculations running for days and by restarting a loose a lot of the calculation effort.
Anyway, even the snippet of code I'm posting leads to a memory leak. I ran it for 1hr (every 4 seconds) and lost around 70MB. With a larger program the leak is higher.
All it does is count the number of .RUN files present in the subfolders. The actual batch is a far more complex, but this appears to be the section responsible for the memory leak.
Does anyone know why this happens? Is there a way to avoid it?
I also tried things like
but it didn't make much of a difference.
By the way, I'm using XP-64bit, but the cmd.exe is only 32 bit. I hope this isn't the reason.
Thanks
I'm experiencing a memory leak while running a batch file.
The file consists of a loop, which runs every 30s. Every time the loop runs, it increases the memory requirement by about 1MB.
The memory is not released once the batch is finished, and doesn't show up anywhere else in the task manager. It's simply gone.
That adds up to about 3Gb a day, forcing me to restart the computer eversday. Doesn't sound like much, but I have calculations running for days and by restarting a loose a lot of the calculation effort.
Anyway, even the snippet of code I'm posting leads to a memory leak. I ran it for 1hr (every 4 seconds) and lost around 70MB. With a larger program the leak is higher.
All it does is count the number of .RUN files present in the subfolders. The actual batch is a far more complex, but this appears to be the section responsible for the memory leak.
Code: Select all
@ECHO OFF
setlocal EnableDelayedExpansion
set /a nmax=0
:Bigloop
set /a count=0
for /f %%c in ('dir /b /s ^| find ".RUN"') do (set /a count=!count!+1)
echo count
timeout /T 4 /NOBREAK
goto:Bigloop
Does anyone know why this happens? Is there a way to avoid it?
I also tried things like
Code: Select all
for /f "tokens=*" %%n in ('dir /s /b *.DTF') do (
By the way, I'm using XP-64bit, but the cmd.exe is only 32 bit. I hope this isn't the reason.
Thanks