amirassov amirassov - 1 year ago 81
C++ Question

c++: multiple copies of a static library in memory

I use a static library in the c++ program. Can memory stores multiple copies of the library? Or for one program, one copy of a static library?

Answer Source

I use a static library in the c++ program

No you don't.

You are using a static library while linking a program, but a finished program contains no trace of the library as a separate entity. There are zero copies of the library in your program.

Your program contains copies of (some of) the object files that live in the static library. Once picked up by the linker, they are on equal standing with all other (non-shared) object files you use (e.g. the one that contains the main function). Having two copies of any of them would be like having two copies of main.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download