I created an executable using static library instead shared lib, I am running multipe instances of this executable, does it takes more memory with static library compare to shared library?.
Does shared library had any advantage than static library in multiple instances?. thanks in advance
4 4405 Banfa 9,065
Expert Mod 8TB
With a static library all the code is in the program. With a shared library the OS loads the library code separately, no matter how many programs are using the library only 1 instance of the library code is loaded.
So yes running several instances of a program linked with a static library as opposed to a shared library will use more memory. The real question though is it significant. If you static library is only a few kbytes in size then it probably makes little difference, if your program creates large amounts of actual data, which is unaffected by the code being in a static or shared library then it is likely that the memory used for data far out-weighs the memory used for code and again it may be insignificant.
It also depends on what operating system your program executes under. Some operating systems deal with multiple instances of the same executable by loading only a single copy of the text section and per-instance copies of the bss and data sections.
Under such an operating system, multiple instances of the same program show no benefit of shared library over static library. Instead, you don't see the advantage until you have two different programs that both include the same portions of a shared library.
I created an executable by linking Nine static libraries, I am running 32 instances of this execuatble in Linux, how I will know whether it is using single copy of text sectioon or multiple of copies, Is there any command in Linux (RH)?. I created Nice shared libs also, but when I created executable using shared libs, it is not working, I have to debug whe my shared libs exe file not working, where as static libs linked exe file works.
I created 9 static libs (x1.a x2.a x3.a....x9.a) and 9 shared libs (y1.so, y2.so,....y9.so) when linking with static libs everything looks ok, but when linking with shared libs, it is not working), for final linking I am using -static when linking with static libs, where as I am not using any flag when linking with shared libs, do I have to use any other flag with shared libs?.
1) this command to create final exe file using static libs
gcc -static -Wall -g -O2 xyz1.o xyz2.o xyz3.o -L/opt/lib -lx1 -lx2 -lx3 ... -lx9 -ldl -lpthread -lm -lstdc++ -o final-exe-file
2) this command to create final exe file using shared libs
gcc -Wall -g -O2 xyz1.o xyz2.o xyz3.o -L/opt/lib -ly1 -ly2 -ly3.... -ly9 -ldl -lpthread -lm -lstdc++ -o final-exe-file
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ohaya |
last post by:
Hi,
I'm trying to understand a situation where ASP seems to be "blocking" of
"queuing" requests. This is on a Win2K Advanced Server, with IIS5.
I've seen some posts (e.g.,...
|
by: Mike |
last post by:
Looking to find any information on how to properly configure multiple
instances of DB2. This is on Win2k db2 ver 7.2. I am basically looking
for information on how the multiple instance settings...
|
by: Abhishek Srivastava |
last post by:
Hello All,
In IIS 6.0 We have a concept of worker processes and application pools.
As I understand it, we can have multiple worker process per appliction
pool. Each worker process is dedicated...
|
by: James Radke |
last post by:
Hello,
I have a multithreaded windows NT service application (vb.net 2003) that I
am working on (my first one), which reads a message queue and creates
multiple threads to perform the processing...
|
by: Olie |
last post by:
This post is realy to get some opinions on the best way of getting fast
comunication between multiple applications. I have scowered the web for
imformation on this subject and have just found...
|
by: John |
last post by:
Does the length of my C variable names have any affect, performance-wise, on
my final executable program? I mean, once compiled, etc., is there any
difference between these two:
number = 3;
n =...
|
by: Mike |
last post by:
Class A
public objX
I want to create 2 or more instances of Class A and have the same value for
objX in all instances.
Instance1 of Class A
Instance2 of Class A
Instance3 of Class A
|
by: =?Utf-8?B?VG9kZA==?= |
last post by:
What is the memory footprint of static methods of a windows app running on a
server when the server spins up multiple instances of the application?
In my envirionment, we have a Citrix server...
|
by: Nethali |
last post by:
Hi folks,
Is there any way to embed shared library directly, to executable file
it self so that executable file can run stand alone without the shared
library.
I don't want to compile the...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |