What if two executable/Dynamic libraries use another common Dynamic library at the same time?
-
Let two exes use same dll in windows platform at particular time.Then what is shared internally?Please correct me if I am wrong. -Dll file in Hard disk is shared(Single copy). -Instructions in Dll are loaded once and code can be used by both the executable. -The objects in the Dlls are also shared by both executable. Please clear me - The mechanism in windows os. whether this is same across all OS. Thank you in Advance.
-
Let two exes use same dll in windows platform at particular time.Then what is shared internally?Please correct me if I am wrong. -Dll file in Hard disk is shared(Single copy). -Instructions in Dll are loaded once and code can be used by both the executable. -The objects in the Dlls are also shared by both executable. Please clear me - The mechanism in windows os. whether this is same across all OS. Thank you in Advance.
DLLs also help reduce memory overhead when several applications use the same functionality at the same time, because although each application receives its own copy of the DLL data, the applications share the DLL code.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
-
DLLs also help reduce memory overhead when several applications use the same functionality at the same time, because although each application receives its own copy of the DLL data, the applications share the DLL code.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
@CPAllinii Thank you for answer. But if two dlls(having same signature) in two different directories and linked by tw different executable. Then what will happened? Is the design same across different OS. Please answer. :^)
-
@CPAllinii Thank you for answer. But if two dlls(having same signature) in two different directories and linked by tw different executable. Then what will happened? Is the design same across different OS. Please answer. :^)
I think you may find the answer in this MSDN page: "Dynamic-Link Library Search Order"[^].
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
-
Let two exes use same dll in windows platform at particular time.Then what is shared internally?Please correct me if I am wrong. -Dll file in Hard disk is shared(Single copy). -Instructions in Dll are loaded once and code can be used by both the executable. -The objects in the Dlls are also shared by both executable. Please clear me - The mechanism in windows os. whether this is same across all OS. Thank you in Advance.
As far as object data (memory), that's not shared at all.... it's just the code that is shared. For example, if you have two exe's using an IO dll, the state of one will not affect the other, they're still independent while running. If you want them to share something, you have to set that up using other means (IPC).
-
@CPAllinii Thank you for answer. But if two dlls(having same signature) in two different directories and linked by tw different executable. Then what will happened? Is the design same across different OS. Please answer. :^)
There's an order by which exe's look for libraries. It will use the first one it finds, I believe CPallini gave you a link that specifies the search order. You can use tools such as Dependency Walker[^] to see what dll specifically is getting loaded by an exe if you're not sure which one it's loading. It is customary that shared dll's are placed in a location where any program that wants to use it has access to it, of course, this will require admin privilidges for your installer (assuming you place the dll copy in a system folder).