|
-
May 13th, 2009, 12:59 PM
#3
Re: Some doubts about dlls and reference counting
1) A copy of the dll will be mapped into each process space. Unlike Win16, the dll will not be shared (i.e. reused).
1a) You'll need to implicitly link to or do a loadlibrary on the dll in each process.
2) When you are done with a dll loaded with LoadLibrary, call FreeLibrary when the reference count goes to zero (for the process), the dll will be unloaded. LoadLibrary/FreeLibrary calls in one process don't effect another process.
3) There are two types of COM servers: in-proc server and out of process servers. In proc servers are loaded into the process space. When their reference count goes to zero they are unloaded. Like 2) above, the COM reference count of an inproc server doesn't effect the same COM inproc server loaded into another process. Out-of-process COM servers are hosted by an exe. As such the reference count is shared across multiple process that load the COM object. In the out-of-process com server, the COM subsystem will terminate (or close) the exe only after all process have called Release on all the COM objects hosted by the server.
Final comments:
In general the data held by a dll loaded into a process is kept separate from the data in the same dll loaded into another process. The exception to this is data that is shared memory section data. In addition, a dll can also shared data by using one of the interprocess communication techniques such as memory mapped files or named pipes.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|