Reputation: 15611
Are shared objects separately loaded for each process or one shared object is shared among them? For example, let's say that some program uses libc.so. Then two processes of this program are launched. Will be this shared object loaded TWO times for each process in their memory area OR will it be loaded somewhere in memory ONCE and mapped in memory of two processes?
Upvotes: 2
Views: 1673
Reputation: 43688
Shared objects are loaded via mmap()
with the MAP_PRIVATE
flag. This means that these are copy-on-write mappings, they initially point to the same memory, but once any of them is modified, it is copied and "unshared" before the modification.
Upvotes: 2