Prev: CppCodeProvider.dll CompileAssemblyFromSource() throws a "not implemented" exception
Next: LPCTSTR vs const char* in Visual C++ 2005
From: Sergey Kashyrin on 25 Mar 2006 18:18 Carl, I've already figured out that compiling with /MD or /MDd and embedding the manifest resolves the issue. There were no problems on XP 32-bit and VS2003. It happened on XP-64bit and 2003 server with VS2005. I think you right about TLS entries Thanks, Sergey "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam(a)mvps.org.nospam> wrote in message news:%23gZYI1EUGHA.4952(a)TK2MSFTNGP09.phx.gbl... > "Sergey Kashyrin" <ska(a)resqnet.com> wrote in message > news:OcH99kDUGHA.4384(a)tk2msftngp13.phx.gbl... >> Here is a short testcase: > > I had no problem with your test case loading all 200 DLLs on XP SP2 w/2Gb > of RAM. > > That said, I wonder if you're exhausting the TLS indices. IIRC, every > copy of the CRT will consume a single TLS entry, and you're loading a new > copy of the CRT with each DLL. > > I changed your sample as follows: > > ------------------------- > pch.h > ------------------------- > #include <windows.h> > #include <stdio.h> > > ------------------------- > pch.c > ------------------------- > #include "pch..h" > > ------------------------- > mod.c > ------------------------- > #include "pch.h" > > BOOL APIENTRY DllMain( HMODULE hModule, > DWORD ul_reason_for_call, > LPVOID lpReserved > ) > { > fprintf(stderr, "dllmain %s: %d\n", NM, ul_reason_for_call); > return TRUE; > } > > __declspec(dllexport) void MOD(void); > > void MOD(void) > { > fprintf(stderr, "Module %s CALL\n", NM); > } > > ------------------------- > main.c > ------------------------- > #include "pch.h" > > int main(int ac, char ** av) > { > int i; > char pgm[16]; > void * x; > for(i = 100; i < 1000; ++i ) { > sprintf(pgm, "M%d.dll", i); > x = LoadLibrary(pgm); > if(x == NULL) { > fprintf(stderr, "error load %s %d\n", pgm, GetLastError()); > break; > } > } > return 0; > } > > ------------------------- > build.cmd > ------------------------- > del *.pch *.dll *.exe > cl -c -Yc -Fppch.pch pch.c > > for /L %%i IN (100,1,1001) do ( > cl -Yupch.h -Fppch.pch /LD /MD /DMOD=M%%i /DNM=\"%%i\" mod.c /link > /out:M%%i.dll > mt /manifest M%%i.dll.manifest /outputresource:M%%i.dll;#2 > del *.exp *.lib *.manifest > ) > > cl -Yupch.h -Fppch.pch main.c > > ------------------------- > Note the use of /MD to use the DLL version of the CRT. Note the use of the > MT tool to embed the manifest for the CRT in each DLL. With those changes > I had no problem running your sample with 1000 DLLs I didn't try higher > than that, but memory usage was only 22Mb at that point, so I suspect I > could have gone to 10,000 or higher with no problem. > > -cd > > > > |