?
Solved

about DLL loading

Posted on 2001-07-19
14
Medium Priority
?
265 Views
Last Modified: 2010-04-06
2 programs are using the same DLL.

Question 1 is :
It there are both launched, how many times the DLL is loaded in memory ? once or twice ?

Question2 is :
If One program is loaded twice. how many times the DLL is loaded in memory ? once or twice ?

regards.
Mike
0
Comment
Question by:gklux
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +3
14 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 6297449
DLL is loaded each time LoadLibrary() is called.
ziolko.
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 400 total points
ID: 6297459
0
 

Expert Comment

by:article
ID: 6297477
The DLL will be loaded only once.  That's why one use DLL to share common codes.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 13

Expert Comment

by:Epsylon
ID: 6297487
:o/
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6297495
as far as i know a dll is allways loaded once, and multiple loads are counted by an referncecounter.

only the memory for vars/structures is
allocated additional for each processwell, i'm not an expert of this,
therefore i may wrong

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6297500
:o/
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6297846
Epsylon's link should explain it all in detail, but in case you're too lazy to read all that stuff, here the answer in short:

"article"'s answer is wrong. Each process loads its own copies of each needed dll. A prove is simple: You can change segments of a dll in the memory context of your own process - and this "patching" shows only effect in the current process. Several API hooking methods are using this effect, e.g. ImportTablePatching works only process wide.

However, there are some exceptions to what I said above:

(1) In win9x based systems there is a shared area ($80000000 - $FFFFFFFF) and a non-shared area ($00000000 - $7FFFFFFFF). The non-shared area is private to each process. Dlls loaded there are also private to each process. Dlls that are loaded in the shared area (some system dlls) are shared among all processes. Those dlls are only loaded once for all processes. In winNT based systems the whole memory area is private, there is no shared area, thus no shared dlls, either.
(2) If some segments of a dll are marked as being shared, these segments are mapped into all processes by Windows.
(3) To boost up the overall speed, Windows internally does a lot of tricks to avoid double loading of dlls system wide. But that's burried in the deepest OS regions and hidden very well. Technics like CopyOnWrite and such stuff help realizing this. But at application level it is really this way, that each process has its own copy of all (non-shared) dlls.

Regards, Madshi.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6297903
as i said, i'm not an expert for this :-)
0
 
LVL 21

Expert Comment

by:ziolko
ID: 6300964
Epsylon's comment confirms what I said earlier: each time LoadLibrary() is called.
ziolko.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6301264
Hi ziolko,

if the same process calls LoadLibrary twice, the dll is only loaded once and a reference count is incremented. Furthermore dlls are also loaded if they're statically linked to by another module, without that anyone calls LoadLibrary.

Regards, Madshi.
0
 

Author Comment

by:gklux
ID: 6301939
Hi all, and thanks for such lot answers.

I Think that Epsylon's answer is the best one.

best regards.

Mike
0
 

Author Comment

by:gklux
ID: 6301941
thanks and regards
Mike
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6302102
thank you too, Mike
0
 
LVL 21

Expert Comment

by:ziolko
ID: 6305340
Madshi thx I didn't know that.
ziolko.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question