When a DLL unload from physical memory??
-
HI, I wonder when a DLL unloads from PHYSICAL memory... I found that each process which attach a DLL has a referrence count for use of it.. And when the count becomes zero it is detached from process and removed from process's VIRTUAL memory address.. THEN,.....When exactly a loaded DLL unloads? (I mean when = which state that satisfies its unloading condition) Does it unload itself? OR Windows OS unloads it? Thanks in advance.. -Ray
-
HI, I wonder when a DLL unloads from PHYSICAL memory... I found that each process which attach a DLL has a referrence count for use of it.. And when the count becomes zero it is detached from process and removed from process's VIRTUAL memory address.. THEN,.....When exactly a loaded DLL unloads? (I mean when = which state that satisfies its unloading condition) Does it unload itself? OR Windows OS unloads it? Thanks in advance.. -Ray
I think a DLL unloads from physical memory when this memory it's needed. As when Windows loads a DLL, it only reserves the virtual memory and maps it to the DLL. If the DLL was not loaded, when the process access it, it causes a page fault, and automatically Windows loads it into physical memory. I suppose the it's the same process when unloading: removing the DLL from memory if RAM it's not needed is a silly task, as maybe Windows must reload the DLL after removing it. I suppose the RAM pages containing the DLL will be marked as they can be used, but if anybody uses this pages, 'reloading' the DLL into physical memory will be a little effort. If I find more information I'll post another message, or if anybody can assure this or correct me, will be pleased!!! :)