Solved

Limit on number of DLLs that can be loaded

Posted on 1998-12-01
12
214 Views
Last Modified: 2010-04-02
What is upper limit on the number of DLL's that can be loaded by an application? I keep hearing 64 DLL's is the limit but can not find any documentation to verify this.
0
Comment
Question by:cmustaff
  • 5
  • 3
  • 2
  • +1
12 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1179018
You might want to try asking this in the windows topic area.  this is not really a C++ question.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1179019
I am not aware of any limit.

The MSDN entry for Windows 95 system limitations does not mention any and I would be surprised if NT had any such limit.

Cheers,

Raymond.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1179020
>> I am not aware of any limit.
Raymond, the "comment" radio button was invented for exactly this purpose.  Locking questions with non-helpful answers or just opinions is unprofessional.

>> this is not really a C++ question.
Sorry, Todd, it is.  See explanation below.

cmustaff, the WIN32 architecture does not contain any limit for the number of DLLs.
However, the C/C++ run-time library (at least the one that comes with MS compilers, possibly others too) uses TLS to internally manage loaded DLLs.  Since it only allocates 64 DLL slots, it effectively limits you to 64 DLLs.  Note that an application that does not use TLS and does not include the C/C++ RTL can use more DLLs.

BTW, you may want to "reopen" the question since the currently pending answer by  rwilson is incorrect.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1179021
It thought that limit was 64 threads, not 64 DLLs.  (and 64 threads on win95 will practically kill the computer anyways)   What the heck does it need to do that depends on the number of DLLs?
0
 
LVL 22

Expert Comment

by:nietod
ID: 1179022
Alex, are you sure you are right about this one?  Granted this is more your area of expertise than mine, but as I understand it, there are (at least) 64 TLS indexes.  That effectively limits you to 64 seperate cases of thread local storage per process.  Now some DLL's may use a TLS slot, like the run-time library, but I don't see any evidence that all will, so you would be limited to 64 DLLs that use TLS.  Now if the DLLs are staticaly linked to the run-time library each might use a TLS slot, but if they are dynamically linked (which is better anyways) they should not.  At least as far as I can tell.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1179023
A bit more checking reveals a way around the limit: don't use the "multithreaded DLL" RTL option.

References:
    http://www.dejanews.com/getdoc.xp?AN=292551568
    http://www.dejanews.com/getdoc.xp?AN=411286011

0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:cmustaff
ID: 1179024
A sample executable built with the debug multi-threaded option
and a statically linked C/C++ RTL was used to load as many DLLs
as possible.  When attempting to load the 65th DLL, the following
MessageBox was displayed.

"Initializatoion of a Dynamic Link Library, ..., failed.
 The process is terminating abnormally".

Changing the "Use run-time library" list option in Project Settings
to either of the following allowed the 64 DLL limit to be exceeded.

1. multi-threaded dynamically linked C/C++RTL
2. single-threaded statically linked C/C++ RTL
0
 
LVL 22

Expert Comment

by:nietod
ID: 1179025
>>1. multi-threaded dynamically linked C/C++RTL
That works because there is only one copy of the run-time library being loaded, so it uses only one TLS slot.  (That is what I suggested above.)
>> 2. single-threaded statically linked C/C++ RTL
That works because although there are multiple copies of the run-time library loaded, tnone of them use any TLS slots.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1179026
alexo - I take your point re: the comment option. However this was in fact the answer to his question (as you point out :-).

If you read his question carefully this will be apparent. I believe my answer stands (re the original question) All you have pointed out is that in some special circumstances there is a 64 DLL limit. Had cmustaff (a staff member at CMU???) pointed out he(?) had in fact reached the limit he quoted in the circumstances he was using this would have permitted the more specialised answer now available to be formulated.

Cheers,

Raymond.

0
 
LVL 11

Accepted Solution

by:
alexo earned 100 total points
ID: 1179027
Raymond, I guess I was too harsh, sorry, should get more sleep.  However, seems to me that "I am not aware of any limit" and "I would be surprised" fit the category of opinions more than answers.

Anyway, the complete answer is:
1. There is no INHERENT limit in Win32 regarding the number of loaded DLLs.
2. The number can be limited by available system resources (an article I provided a link to mentions ~500 in certain configurations).
3. The use of TLS by the DLLs can exhaust TLS indexes and effectively limit the number of loaded DLLs to 64.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1179028
>> However, seems to me that "I am not aware of any
>>   limit" and "I would be surprised" fit the category of opinions more than answers
I would have to agree.  
0
 

Author Comment

by:cmustaff
ID: 1179029
alexo's answer provided the clue that was needed to reset the run-time options in the
VC++ project studio settings.  Thanks
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now