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?
Asked
Active
Viewed 1,558 times
2
-
Shared objects are called "shared" for a reason. – n. m. could be an AI Jul 23 '12 at 19:09
2 Answers
2
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.

ninjalj
- 42,493
- 9
- 106
- 148