Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   DLL Linking performance problem (http://www.programmingforums.org/showthread.php?t=58)

SimonGL Jun 14th, 2004 7:45 PM

Hi,

I am facing an issue when using my code as a DLL. I wan tot sahre my code to somepeoples as a DLL. When I test it inside my project, it runs very fast. But when I build a Dll from it and link to it, it runs much more slower.

Somebody have an idea?

Thankx

And thanks to big_k105 for this great forums :D

unknowen Jun 28th, 2004 12:08 AM

Are you using that dll code in your project straight or by loading dll, it takes time to load dll into memory for first time, but then everything should work faster.

kurifu Jul 7th, 2004 2:16 AM

Next question is which compiler are you using? Some compilers will actually statically link the "DLL" intended code directly into your project, meaning the exported functions are actually imported into the project and loaded when the main binary is loaded.

Now most DLLs when you link them using a .lib file (and use the compiler's DLL wrapper function to call exported functions within the DLL) will not load the DLL into the virtual memory until the first function call within the DLL. It may also decide to unload it at some point if you do not use it often or you system thinks that it is not going to get used again... this can be very tedious on the processor and memory, especially if you export several functions, or a few large functions, or even both.

If that is the case, try not using the .lib file with your project and manually calling the DLL functions--Of course your DLL functions will have to be exported C style if you want to do this by any reasonable means--and then loading you libraries at application load with the Win32 LoadLibrary( ) function (at least I think that is what it is called, to much Linux + KDE recently makes me forget).

I did write a DLL wrapper some time back and open sourced it, VERY handy for this sort of thing, even gives you a semi-complete plugin framework (such that it is API independant). Take a look at the cmr::MDLLProxy class within the project. Visit http://www.cliffordroche.com goto the projects page, and download the CMR Namespace Project.

Good luck...


All times are GMT -5. The time now is 4:26 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC