LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CPU usage Digital Read

I am using a cDAQ 9172 with a NI 9421 input card. My PC is 2.4GHz/512mB Ram Win XP SP2 with no other apps running.
 
I call my monitor input VI(see enclosed VI) in a loop.  For testing I am running only this loop.
If my Wait in the loop is set to 1ms, the CPU usage is high 60-70% and it slowly climbs to 90-100%.  At that CPU usage other loops(in the real application). are affected.
 
By increasing the Wait time to 30ms the CPU usage starts low (10%) but over 4-5 hrs climbs to 90-100%
 
I've searched through the messages in this forum, but have not found a solution.
 
Help! 
0 Kudos
Message 1 of 3
(2,739 Views)
I would recommend moving your obtain notifier VI's out of the sub-VI and outside of your main loop so that the notifier is only obtained once, and the reference is passed into the loop and into the sub-VI's
 
Look at the help for release notifier especially the underlined, bold, italic part.
 

You can use the Obtain Notifier function to obtain a reference to the same notifier with the same name multiple times. To destroy a notifier, call the Release Notifier function a number of times equal to the number of times you obtained a reference to the notifier or stop all VIs using the notifier reference.

If force destroy? is TRUE, this function releases all references to the notifier and destroys the notifier."

If it says you should call this function once for each time it is called, it must be building up numerous copies of this reference in memory.  By slowing the loop from 1ms to 30ms, you are obtaining notifiers at 1/30th the rate, thus the program runs longer before bogging down the computer.  Call it once (for each notifier) outside the loop, pass the references into the loop and into the sub-VI, I think the performance will improve.  And of course make sure you use the release notifier in you main VI once your loop exits and the program is ready to end.

Message 2 of 3
(2,730 Views)
Thanks, that seemed to solve the problem. 
0 Kudos
Message 3 of 3
(2,699 Views)