Strange issue using DirectX in Mixed-Managed DLL

Ilfirin

Regular
This probably isn't the best place to ask this question, but here goes..

So I've been developing some visualization software for this company that uses a managed interface to un-managed, regular C++ code using DirectX (in non-managed mode) all in the same DLL.

Everything was working great until, seemingly completely randomly, the DLL started taking 15-30 seconds to load. The only change made between the previous release that didn't have this problem and this one was some insignificant (I think it was just allowing the user to select between perspective and orthographic projections) property exposed to the managed API. No major code changes at all and no changes to the project's compile options or anything and it just randomly goes from taking a couple milliseconds to work to taking 15-30 seconds.

The software company that is uses the library says that all of a sudden they're getting a lot of disk activity and that they think it's constantly loading and unloading the directx libraries. I can't duplicate this on my end and the debug output isn't mentioning anything of the sort (plus the libraries are statically linked and should remain active the entire time my DLL is active).

Has anyone ever encountered anything at all like this? It seems like it must be some random bug with the Visual Studio 2005 compiler or something, but I'm open to suggestions.
 
Well, I fixed it.. I'm not sure why what I did fixes it but it does.

The problem was that, even though all debug code and information was NOT supposed to be included in the executable (as it was all disabled for this release), for some reason visual studio's debugger was still jointed in, generating millions of managed->unmanaged->managed code translations (even though 99.99% of the program is written in unmanaged with only the [extremely simple, extremely rarely called] DLL interface exposed through managed code). When I switched the debugger (which isn't supposed to be present) to Native-only, all the managed->unmanaged->managed translations disappeared and everything was back to working in a matter of a few milliseconsd instead of 30+ seconds.

Yay!

If anyone has any information on WHY this fixes it, please inform me :)
 
Got the same problem myself in a project. It due to the .Net runtime changing the way it acts if the process is *started* debugged. My experience has been if you attach the debugger to the process after startup, there will be no performance problems.
 
Back
Top