On 08/02/2013 at 02:51, xxxxxxxx wrote:
User Information:
Cinema 4D Version: All
Platform: Windows ;
Language(s) : C++ ;
---------
Hello Maxon, fellow plugin developers,
yesterday Phoenix and I were investigating the problem where, if too many plugins or dlls are loaded, no additional dlls would load.
It came to my attention when some of our dependencies (namely cuda and opencl) stopped working for some users.
We have found that it is related to the fact that virtually all plugins (as well as nvcuda.dll and opencl.dll) are using the statically linked CRT.
It seems a process can only initialise a few static crts before loading additional pluigins or dlls using the static CRT will simply fail (this is a fairly well known problem:
msdn discussion
stackoverflow )
In my tests (I generated 200 simple command plugins with unique plugin IDS) I found that after loading 73 plugins no further plugins can be loaded.
The simple solution to this problem: Using the dynamically linked CRT. When linking all 200 simple command plugins with the dynamic CRT all 200 plugins load (of course the appropriate VC++ redist must be installed on the system or the crt dlls must be in some location C4D is aware of in general)
In VS linking the dynamic CRT can be enabled in the Project settings > "C/C++" > "Code Generation" by setting "Runtime Library" to "Multi-threaded DLL (/MD)".
If you want to test this behaviour yourself, here is the archive with 200 plugins (x64) using the static CRT:
200 plugins static CRT R12+.zip
And here are the same 200 plugins using the dynamic CRT:
200 plugins dynamic CRT R12+.zip
(requires the VC++ 2012 x64 redist)
Unless Maxon advises strictly against using the dynmaic CRT we can only fix this problem if we all link our plugins with the dynamic CRT - it is a massive hassle for all users and I am sure has cause some headache for a few of you already.