Dynamic link libraries and shared memory:

Dynamic link libraries and shared memory:

       We know that the use of dynamic link libraries (.dll performance on the windows, the performance of .so under linux) is delayed loading mechanism, that is in the process of running the program will be loaded when they were called. There is only one copy of a DLL in memory, and can be shared by multiple processes. Obviously doing so can save memory space.

  So the question is: is there is only one shared memory, it can be shared by multiple processes in memory. In a different process, addresses are allocated shared memory of that period will be different. Well, the same is there is only one copy in memory, the same can be shared by other processes, the difference between dynamic link libraries and shared memory Where is it?

  The difference is that: While multiple programs can share the same code as a dynamic link library, but each process all the data used in the dynamic link library assigned its own address space. The shared memory is a plurality of program code and data are shared. Dynamic link library only achieve code reuse, data for each program you want to save yourself. Shared memory for inter-process communication, mainly used for shared memory data. It also reflects the dynamic link library and can not be used to communicate between processes from the side.

Guess you like

Origin www.cnblogs.com/tongyishu/p/11722004.html