05-03-2012 02:54 AM
Hi,
I'm using Labview 2011 SP1 under windows 7 32bits. I encounter something strange that I can't explain. My program run so fast that I don't understand why?
In my program, a while loop runs more than 1000000 times during approximativley 2500ms. I throught that under windows time unit was ms and us under RTOS.
Can anyone help me to understand what happened here?
thanks
Solved! Go to Solution.
05-03-2012 03:05 AM
If you don't have any delay inside the while loop it will run very fast depending on your processor speed but am not sure about the number you have mentioned. Please explain what is the exact problem you face here.
05-03-2012 03:32 AM
That right, I haven't explain my real problem.
A developper ask me for help due to memory leak problem.
The vi is using producer/consumer structure. When I run the program, the used memory increase a lot. This memory is never release even at the end of the execution and I need to quit all labview instance to release memory.
I've looked for memory allocation but there isn't any. In the structure, there was no timing. So I put a wait until 1ms in the producer loop (classical) but the execution duration was multiplied by at least 15 times but there was no more memory leak !
I've run many tests to understand. Here is some results :
Case 1. No timing => total execution duration 15s // Memory leak ++ // Cpu load 70-90%
Case 2. Wait until 1ms => total execution greater than 3 minutes // Memory leak- // Cpu load 10-20%
Case 3. Wait until 1us (using RT palette) => total execution greater than 2 minutes Memory leak - // Cpu load 10-20%
Case 4. Wait until 0 us (yes 0) => total execution 40s No memory leak // Cpu load 90-100%
So finally the 4th solution work fine but I don't understand :
- The difference between point 3 and 4 as I'm under windows
- Especially the execution time + memory leak in the first case.
I'm not sure I'm clear here...
julesjay
05-03-2012 03:35 AM
Could you post the vi or a simplified version of it?
Regards,
Marco
05-03-2012 06:53 AM
Sounds like a race condition to me. 🙂
/Y
05-03-2012 07:53 AM
Post images of the code to help us help you.
But since you did not post any that give me license to speculate...
You are using a producer/consumer and the producer is pumping stuff into the queue as fast as your CPU allows. When running without the wait the queue fills faster AND the CPU is not being released to allow the consumer to empty the queue so the data piles up in the queue and it looks like a leak.
Did you try a "zero MS wait" (a Wait MS with a "zero" wired)?
That will take the producer thread out of the CPU at let other threads get a crack at catching up. Provided there are no other threads waiting, the zero ms wait will introduce only a small delay while the Task Scheduler decides who get the CPU next.
Search on "Cooperative multi-threading" or something like that to learn how LV handles multiple threads... blah blah blah
Ben
05-03-2012 10:10 AM
Here is an example. I can reproduce my problem with it!
Try 0, 1 and no timing check CPU rate and memory usage!
Thanks
05-03-2012 10:27 AM
Place a "get queue status" after the case structure in the lower loop and display the "# of elements in queue" on a chart.
wait=1: zero all the way
wait=0: zero to a couple of hundred
wait removed: rapidly increasing, to hundreds of thousands within seconds
This is expected.
05-03-2012 10:52 AM
@altenbach wrote:
Place a "get queue status" after the case structure in the lower loop and display the "# of elements in queue" on a chart.
wait=1: zero all the way
wait=0: zero to a couple of hundred
wait removed: rapidly increasing, to hundreds of thousands within seconds
This is expected.
SpoilerAnyone remeber the show "Name that Tune" where contestants would compeat to se who could name a tune based on the lest number of notes?
We can name that memory leak with three hints.
Ben
05-03-2012 11:19 AM
So how do you explain the memory increase when there isn't any timing? Is it due to windows?