06-14-2013 06:08 AM
Hi,
I'm having some trouble debugging a project...
Problem:
Every once in a while, all my Vi's in the project seem to freeze up or execute extremely slow. The machine's CPU load rises to 100% (99% for the LabVIEW.exe process). The normal CPU load with the application running is around 10-15%.
Windows and LabVIEW are still responsive, albeit very sluggish. I can run the "Performance and memory" tool but I can't find any abnormalities.
Question:
Is there a way to find out what's causing the high CPU load? For example by showing the CPU load per VI in memory.
Any input is appreciated.
Kind regards,
Pieter-Jan
06-14-2013 10:12 AM - edited 06-14-2013 10:13 AM
It is highly likely that you have a loop that has no wait in it. As a result of this, the loop is spinning as fast as it can, eating up all your CPU time. Introducing a wait of even 1 ms will work wonders for your CPU usage. 1 ms is too short for us to accomplish anything in, but to a computer, 1 ms is an eternity, and it can perform several tasks in that amount of time without breaking a sweat.
[edit]
Oops, I didn't read that it happened randomly which makes it slightly less of a possibility.
06-14-2013 11:14 PM
When several VI is running then if you open the task manager -> process then it will show only labview.exe. then if you go to resouce monitor and see then also you will see only labview.exe. So I dont think that you will be able to watch per VI.
On the other part if you open chrome with multiple tabs then for all the tabs there is one chrome.exe you can see on the task manager.
May be NI has implemented in that way.
06-15-2013 06:29 AM
I'm just going to reiterate what bilko said. Make sure you have a wait somewhere in each of your loops. Any event structure, enqueue, wait on notifier, anything else with a timeout, or even a Wait (ms) with a 0 wired to it will off load the CPU so other processes can work.
Something like this is almost never random. Are you building large arrays? I've seen things slow down when your memory usage gets large. Can you post the VIs? Maybe another set of eyes will spot something.
06-15-2013 07:29 AM
@Pianne wrote:
I can run the "Performance and memory" tool but I can't find any abnormalities.
Can you be more specific what you mean by that? Maybe you are not using the tool correctly or are looking for the wrong "abnormalities".
All that should be needed is to enable the profiler, run things for a while until the problem appears, and look at the time column. The offending VI should stick out visibly! Now open the subVI and, if the problem is not clear to you, post it here.
For more details, have a look here.
Good luck!
06-24-2013 07:33 AM
Thank you all for the replies. I was out of the office last week and didn't get a chance to reply untill now.
My first thought was also a loop with no timing in it, like billco suggested. The problem is finding which loop is causing the problem, as six seperate loops run continuously and make a wide variety of subVI calls, some static, some dynamic.
@altenbach: The profiler will only show VI's that have started and terminated execution. This means that if I start the profiler when the applicaton has already frozen, I can see very little happening.
I could start the profiler before starting any of the VIs, but the problem usually only occurs after hours or days of running. And when it freezes, I can nolonger shut it down properly.
I have attached two logs of the profiler: One during normal operation and one while the application was 'hanging'.
@crossrulz: I've checked memory usage in the task manager, and it is not excessive.
The project is a bit large to post here (around 300 VIs).
Also, the total CPU load goes up to 100%, but when I tested with a single untimed loop I can only get it to go up to 50% because it's a dual core machine and a single loop can only take over one of the processor cores. This makes me question the theory of the untimed loop...
Any ideas?
06-25-2013 04:34 AM
Hello Piane,
Didn't you mention that you had 6 parallel/seperate loops.
This said couldn't it then be that you have 2 (or more) loops in parallel both trying to go as fast as possible.
In that case it would be possible that both loops are each "dominating" one core.
Another thing I'm personally curious about.
Can you set (in task manager) the Affinity of the LabVIEW.exe process to only one of the cores?
Do you get then 50% (or something in the vicinity of that)?