wbiker Posted September 8, 2007 Report Share Posted September 8, 2007 Hello, I have a problem with quite complex VI. The problem is that when I'm trying to finish (by clicking STOP BUTTON in an event structure) VI gets suspended, CPU ussage goes to 100%. This state can last a few minutes or forever. This behaviour can be seen mainly after long time VI working. Application was tested under LV 8.2 and 8.21 as .exe and .vi - behaviour is the same. Thanks in advance for your help. wbiker Quote Link to comment
Rolf Kalbermatter Posted September 8, 2007 Report Share Posted September 8, 2007 QUOTE(wbiker @ Sep 7 2007, 02:28 AM) Hello,I have a problem with quite complex VI. The problem is that when I'm trying to finish (by clicking STOP BUTTON in an event structure) VI gets suspended, CPU ussage goes to 100%. This state can last a few minutes or forever. This behaviour can be seen mainly after long time VI working. Application was tested under LV 8.2 and 8.21 as .exe and .vi - behaviour is the same. Thanks in advance for your help. wbiker By clicking the stop button on the toolbar you are not stopping the VI but really aborting it. If the program execution was at that point in an external code part you can end up with a locking situation since the external code may wait one some event message processing which will not happen anymore since the whol application was basically taken down brutally. Most NI drivers especially in newer LabVIEW versions are writting in such a way that they get informed by LabVIEW about aborts so that they can abort any waiting, but third party drivers usually don't have that, also because the means to be informed by LabVIEW about aborts are not really documented. But even NI drivers can still sometimes get stuck in such a way. The toolbar stop button is really just a last measure to abort a program or for quick and dirty testing but should not be used as normal way of starting and especially stopping a LabVIEW program. The LabVIEW program should have some sort of event processing with an explicit quit button in which case the event processing loop (and any other parallel loop that might be running) gets properly terminated after which you can clean up any DAQ, Instrument, IO-Bus, etc operation properly by closing those resources and once the last item on the diagram has executed the program stops too, but this time cleanly. Rolf Kalbermatter Quote Link to comment
crelf Posted September 8, 2007 Report Share Posted September 8, 2007 QUOTE(wbiker @ Sep 7 2007, 05:28 PM) The problem is that when I'm trying to finish (by clicking STOP BUTTON in an event structure) VI gets suspended, CPU ussage goes to 100%. Show us your code - we really can't diagnose the problem without it. Quote Link to comment
wbiker Posted September 8, 2007 Author Report Share Posted September 8, 2007 QUOTE By clicking the stop button on the toolbar you are not stopping the VI but really aborting it. I wasn't clear enough, sorry. My applicattion has special even case to handle the stop action. The problem appears on execution the stop event case. QUOTE Show us your code - we really can't diagnose the problem without it. It is really big application to show the code I would have to present ~200vi's. Please give me just some ideas what it can be. Thanks wgbiker Quote Link to comment
Rolf Kalbermatter Posted September 8, 2007 Report Share Posted September 8, 2007 QUOTE(wbiker @ Sep 7 2007, 04:02 AM) It is really big application to show the code I would have to present ~200vi's.Please give me just some ideas what it can be. Most likely you either call some external code incorrectly when this event occurres or probably also possible you do not close properly some functionality contained in external code which makes it hang. Another possibility is that you have multiple loops in your application and one of them instead of exiting too, starts to run freely without any asynchronous delay function in it anymore. But without seeing some of your code and preferably a seriously scaled down application that exhibits still this behaviour it is not possible to give you more specific advice. Rolf Kalbermatter Quote Link to comment
crelf Posted September 8, 2007 Report Share Posted September 8, 2007 QUOTE(wbiker @ Sep 7 2007, 07:02 PM) It is really big application to show the code I would have to present ~200vi's. Please give me just some ideas what it can be. There's a whole lot of things it could be - really, a lot. Make a little example from scratch - try to encapsulate the issue, then we can help (or you might find that you find the problem yourself). Quote Link to comment
george seifert Posted September 8, 2007 Report Share Posted September 8, 2007 QUOTE(wbiker @ Sep 7 2007, 02:28 AM) Hello,I have a problem with quite complex VI. The problem is that when I'm trying to finish (by clicking STOP BUTTON in an event structure) VI gets suspended, CPU ussage goes to 100%. This state can last a few minutes or forever. Thanks in advance for your help. wbiker Are you using VISA? If you don't specifically close your VISA references that can cause your problem. I know, 'cause it's happened to me. George Quote Link to comment
Eugen Graf Posted September 8, 2007 Report Share Posted September 8, 2007 How do you exit the programm? Try Exit LV out, it should close all references and interfaces automaticaly. Eugen Quote Link to comment
Grampa_of_Oliva_n_Eden Posted September 8, 2007 Report Share Posted September 8, 2007 I agree with the previous posts that we need an example to be helpful. Lacking that, i'll speculate. I have seen LV hang if a reference is closed and in a parallel thread the now closed ref is used. So check your ref closing order and/or check the validity of the ref before using it. Like I said, just speculation. Ben Quote Link to comment
wbiker Posted September 12, 2007 Author Report Share Posted September 12, 2007 Hello again, I have found a probem!! (but I still i don't know why it occures:( ) In one of the SubVIs there are dynamic events used in order to refresh Front Panel during the measurement. This solution is used because measurement loop is inside another SubVI. The problem is that after starting the measurement memory consumption (can be observed in Task Manager) is getting higher and higher (should be almost at the same level) so after 1000-th iteration it is about 150MB. This "memory leak" is the reason why entire application gets stuck at the end. I simplified the VI I mentioned so it is possible to run it without any hardware, I put it as an attachement. Could you please look at this and give me some advice. Thanks in advance wbiker Quote Link to comment
Ton Plomp Posted September 12, 2007 Report Share Posted September 12, 2007 QUOTE(wbiker @ Sep 11 2007, 04:57 PM) Hello again,I have found a probem!! (but I still i don't know why it occures:( ) Thanks in advance wbiker Hi wbiker, good you already found the memory leak. It made it quite easy for me to find the problem. You should register for the events outside the while loop. Now you re-register every time the while loop executes (for every event). So register before the while loop (and unregister after the while loop) Ton Quote Link to comment
wbiker Posted September 12, 2007 Author Report Share Posted September 12, 2007 QUOTE(tcplomp @ Sep 11 2007, 03:28 PM) Hi wbiker,good you already found the memory leak. It made it quite easy for me to find the problem. You should register for the events outside the while loop. Now you re-register every time the while loop executes (for every event). So register before the while loop (and unregister after the while loop) Ton Thanks a lot !!! Now it works fine. wbiker Quote Link to comment
Ton Plomp Posted September 12, 2007 Report Share Posted September 12, 2007 QUOTE(wbiker @ Sep 11 2007, 05:47 PM) Thanks a lot !!!Now it works fine. wbiker One of the problems is that you rely on the 'auto-cleanup' facility of LabVIEW. You should delete every queue and user event on finishing the VI Ton Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.