LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Memory usage in buffer update

I create a 2D(6000x1000) array as buffer. When new data come, it will update the buffer.

 

When the new data bigger than the buffer, only the end of the new data with same size will update into the buffer.

The buffer works as around. A pointer record the index of where should the data write to. If the end of the buffer is reached in updating, the new data will write to the beginning of the buffer.

 

It is done by the attached vi. And it will keep working all the time.

 

But after running the whole project for sometime, it seems will hang there slow down.

 

With the statistical results, it seems ocuppy a lot memory.

 

Any suggestion, thanks.

Download All
0 Kudos
Message 1 of 4
(2,422 Views)

Hi Alex,

 

Let me start by admitting this reply is a non-answer to your question, but I do hope to be able to help.

 

Prior to the Polymorphic version of the Queues being introduced (was it LV 6i ?) I used round-robbin or circular buffers to share data between threads. But since then I have discovered that I can use queues instead. So I have abandoned my round-robbin buffers (I don't even remember  the last project I used them in!) and now use queues.

 

Queues are faster because they can transfer the data "in-place".

 

Note: The following is speculation on my part and I have never read NI telling us exactly how they implemented queues.

 

It appears that when we queue up data to a queue, we are not moving the data in memory but rather only a pointer to the data buffer in memory. When the data is dequeued, the pointer is returned by the de-queue operator and IF THE CONSUMING CODE is developed properly, the data can be accessed in it original buffer.

 

There is no way I could match that trick with a circular buffer.

 

So I suggest you swtich to a queue and set teh buffer aside on the shelf.

 

If you still want to learn what is happening in your code, then please review the threads that have been tagged with the term "LabVIEW_Performance" and the related tags.

 

Pay close attention to all threads that talk about "in-place" or "inplaceness".

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 4
(2,404 Views)

Ben, thank you so much for your suggestion. I use queue for transfer data quite a lot, but not use it as a buffer directly before.

 

Actually I need a circle buffer, when I do is using the queue to transfer the data into the loop and use loop register to record it.

 

If use queue to replace a circle buffer, it need to be able to write to the certain index of the queue. May I know how you use queue to replace a circle buffer.

 

Thanks.

0 Kudos
Message 3 of 4
(2,382 Views)

A queue can have an limited number of elemnts. They are returned in the same order the where queued.

 

Tell us a little more about your situation if the queues do not meet your needs.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 4
(2,365 Views)