On Sat, 18 May 2013 20:40:41 +0200, henry albrecht <
h...@gmx.de> wrote:
>
I suspect this is the OS keeping the file locked for paging.
Windows memory management (MMS) optimizes paging for executables by
loading the executable binary and loading it into memory, if it needs
to discard a page it uses the LRU algorithm to discard executable
pages and rather than write them out to the page file it simply
discards them since reloading it from the executable image is a
convenient source and immutable. (Windows has done it this way since
its first inception.)
In the mean time, the file is locked so that it can't be discarded or
moved out from under the MMS while the program is running. Once a
process exits, the paging system unlocks all open resources and frees
the memory and since the system can't know if you are going to invoke
the program again, it takes its time getting rid of those locks.
A page is 4kB on Windows so even a small executable like
helloworld.exe is subject to this behavior.