NI TestStand

Showing results for 
Search instead for 
Did you mean: 

Delay when calling functions in DLL



I have a strange problem: it takes longer then usual to execute a function in the DLL.

The DLL is written in Visual C++ and was provided to me by my customer. It makes calls to a motor controller (serial) and talks to the DUT using CAN (PCI8512/2). When I reboot the computer it runs as expected. Once I stop it (using TerminateAll form TestStand) and re-run it, all calls take longer to execute. Like 3-4 times longer. My total test time goes up from 100 sec to 400 sec and more. 

I checked the Windows event viewer, ran self test on CAN cards, no indication of any problems.

When I shipped the tester 2 months ago it wasn't doing this, and I was integrating it for 3 or 4 weeks, so I would have noticed for sure.

Also, I shipped 5 systems like this and they all have the same problem that developed in the last 2 weeks. 2014 bug?


Any ideas appreciated.




0 Kudos
Message 1 of 3

Not aware of 2014 bug which can cause this.


Few things you can try :


1) Since after rebooting its fine for the first time - is there a memory leak which is slowing execution?

After you terminate your sequence - just restart TS or use file-->unload all modules and try re running.


2) Debug file/dll used? Try with release file.


3) Has anything changed in the DUT software which is resulting in this.Try to simulate with CAN itself ( removing DUT from the loop).


4) If nothing works then split your code into different sections and log with time stamp at those points.See between which points the time taken is more.You will be able to hit the issue.


Hope this helps.



0 Kudos
Message 2 of 3

Do you have to reboot or does just restarting TestStand make it faster again? If you have to reboot then this probably does not have anything to do with TestStand directly.


Have you narrowed down where the extra time is being spent? Is it in your dll code module? If so where in that code? You might want to add timing code to your dll to determine exactly where things are getting slower. Once you've done that, you will then know what is slower. Once you know what is slower it will be easier to determine the cause of the problem. Perhaps it's a driver your dll is calling? Have you updated any drivers recently since before the problem was happening?


If you do narrow it down to a driver problem, you might either try installing a newer version of the driver and/or getting support from whichever group or company is providing the driver.


Timing things inside of a sequence is quite easy. You can do something like the following in an expression:


Locals.starttime = RunState.Engine.SecondsSinceStart


Then elsewhere in the sequence do:


Locals.elapsedTime = RunState.Engine.SecondsSinceStart - Locals.starttime


Then compare various sections of code before and after the slowdown until you narrow down where the problem is happening.


Hope this helps,


0 Kudos
Message 3 of 3