3 ms·
Windows memory-maps the DLL file from disk into virtual memory (a la MapViewOfFile), causing the filesystem lock. While I’m not sure why this was done, I specu
by invokestatic 8y ago
Windows memory-maps the DLL file from disk into virtual memory (a la MapViewOfFile), causing the filesystem lock. While I’m not sure why this was done, I speculate it has something to do with saving memory back in the 9x days or even earlier. It’s possible to write a DLL loader that reads from the file once and copies the bytes to memory, leaving no lock unlike memory mapping the file.
But even so, there’d be no way to reliably reload DLLs running in a process, not to mention that there are usually hundreds of them running in any particular process. I can also imagine issues arising if existing processes continue to run an old DLL where a new process has a newer, updated DLL such as with IPC, or if there is a zero-day in a DLL used by a long-running daemon. All around, restarting is the safest bet.