LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Not enough memory error when passing an array to a chart

Hello.

I am trying to pass some data from a reading loop to a display loop using queues and charts.

In order to save on redraws I am reading the queue just once a while, flush it and pass the resulting array to the Chart. It is actually an array with clusters of three values.

Everything works fine unitl I actualy want to display the chart. I can pass the data and see it using an indicator without any problems.

When I wire the data to the chart it randomly shows : "not enough memory to complete this operation"

The fact is the array being passed to the chart is of random size.

The queue size is good for about 20 min. Labview shows an error after a few seconds. After clicking ok it prints out the results correctly and then a second or two later same error.

 

What am I missing here? Thanks

LV 2012 f3 I7 2.4GHz 16GB RAM

0 Kudos
Message 1 of 17
(3,880 Views)

Where does the error come from? You do not have any error wires connected, so that implies that you are using automatic error handling. Is the error in the VI you posted or in the VI where you are enqueuing the data?

 

The charts are ~1700 pixels wide and have history length of 1024. It does not make any sense to connect more than 1024 point to the chart. Any more than that are reduced to fit by the internal code of the chart itself.  The 240000 elements in your queue will not fit into the chart.

 

I suspect that you are doing something in the enqueuing code which is causing the problem.

 

Please tell us the wholw picture so we can help.

 

Lynn

0 Kudos
Message 2 of 17
(3,864 Views)

You will be better off NOT using the flush queue.  The reason is because you are copying a potentially huge array when you perform the flush.  Go ahead and use the Dequeue and write to the charts.  The front panel does not update with every write, so the redrawing shouldn't be that much of an issue.  You also won't need the wait in the loop that is reading the queue.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 17
(3,861 Views)

What is the point of generating these up to 240000 element arrays if the chart history lenght is only 1024 elements. You are filling a huge baloon, just to thrown most of it away a nanosecond later.

It would use less memory if you would place the two chart terminals inside the for loop. Even more efficient would be to just clip the last 1024 points from the array before doing your inner for loop.

0 Kudos
Message 4 of 17
(3,859 Views)

There is no LV standard error.

It is a new small window with a message and an OK button.  The message says: "The is not enough memory to complete this operation." Then I click ok and the results gets printed out ok and then another message pops up.

I tried the history length of 4000, 50000 and get the same error right away.

 

The 240 000 elements is the maximum size of the buffer and at this point I care if the chart holds the last 4000 or so.

 

The enqueuing is almost a twin loop that stuffs a single element into the queue.

If I remove the chart it runs without any errors or messages and I can see good results through an indicator.

0 Kudos
Message 5 of 17
(3,855 Views)

Not sure if it helps or not but here is the error.

I put about 200 elements/s in the queue. That is why instead of reading it 200/s I just want it to read it once a while.

I am not sure what is a bigger burden:copying one 500 elements array twice a second or 200/s and 200 calls to the Queue.

 

The max size of the queue is not important here. I can set it to something more reasonable and will get the same error.

What will happen to my CPU usage if I put the Chart in the for loop and make 500 call to it? And then half a second later another 500 calls?

 

As I said at this point I do not know how much history I need or not but all I want is to be able to see a few s of it. If I loose the rest it is ok for now. 

Lets says that all I care is to see it close to real time with a history of 5s. It would mean the queue buffer size of  1000.

 

Back to the main problem: why do I see the memory error  window when I know clearly that I have plenty of memory left.

 

0 Kudos
Message 6 of 17
(3,846 Views)

And here is the second loop  that feeds the data in (snippet).

Thre is nothing fancy about it.

It keeps stuffing 7 integers encapsulated in a cluster to the queue.

 

Thanks for lookin at it.

0 Kudos
Message 7 of 17
(3,843 Views)

When I make a simple change like that- printing to an indicator instead of a chart it all works just fine.

It does not matter what are the sizes of queue buffers.

 

It has somethingto do with the way LV handles memory for charts but I do not know how to force it to be happy.

0 Kudos
Message 8 of 17
(3,827 Views)

You're probably filling the queue alot faster than you're dequeueing it, filling up memory.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 17
(3,812 Views)

With 240 000 elements it is exaclty enough for 20 min. I get the error on the first call to the chart.

It does not have this issue when using the graph. Also no automatic history...

0 Kudos
Message 10 of 17
(3,805 Views)