static variables inside shared library

Hello All,

I am creating a class and linking it to a shared library. The class has a static map variable. (in the class scope not global).

My question is, if multiple processes access the shared library, will they get the same copy of map (since it is static) or will they have different copies?

Will modification of the map in one process gets reflected in other processes which use the shared library also?

Thanks in advance
Nanda
Different. You know, since you've already written the code, you could just try it out yourself.

Hello Mr.jsmith,

I am usiing the lib for a single process. I tried using lib for 2 processes by running them concurrently. As said by you, they had different copies of static map. Thank you for your information.

But i could not understand the mechanism. Can you explain what happens in this case? I heard that shared library is only loaded once even if multiple processes gets created.
The shared library executable code is loaded only once. Each process gets its own
copy of the data segment.
Thanks once again!
Topic archived. No new replies allowed.