From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Memmory allocation

Hello,

I have problem using in my sistem an global variable. Its type is array of clusters and its dimension could increase up to 20000 elements. I don't know from the beginning of the execution the dimension of it, so in the initialisation phase it has no elements. So for each itteraction I add new element.
The problem is that ... increasing a lot, the execution time is also increasing :?( and also I have no idee when memory it is dealocated ...

Have a nice day!
Message 1 of 4
(2,665 Views)
I've found two useful documents on memory allocation in LabVIEW. One is online and is called "Managing Large Data Sets in LabVIEW". The other is a help file that came with LabVIEW and is called "LabVIEW Performance and Memory Management". They both give information about when memory is deallocated and tips for obtaining the best performance. Good luck!
0 Kudos
Message 2 of 4
(2,640 Views)
Memory allocation in LabVIEW is done for you automatically. This is great for most cases, but not for yours, since you have a fair amount of data. I would recommend a few things:
  1. Check out the tutorials on LabVIEW Performance and Memory Management and Managing Large Data Sets in LabVIEW. They contain a lot of information on when data is allocated and how to control it. The latter one contains a large data storage implementation you may want to use.

  2. Don't allocate memory at every step. Allocate it in chunks, then consume the chunks. Hitting the memory manager for large amounts of memory is very time intensive. A common allocation method is to double your allocation every time you run out of space. This will make your code more complex, but it will also be a lot faster. When you finish, you can trim your allocation down to the necessary size, if needed.

  3. Stop using the global. Every time you read it, you make a copy of all the data in it. In addition, with the parallel nature of LabVIEW, it is very easy to create a race condition. For example, you read the data at one place in your code, then you read it in another place. The first place then changes the data, followed by the second place changing the data. The changes made by the first place will be lost, overwritten by the changes made by the second place. I have attached a file containing a way to store data in LabVIEW so it is globally available, but also can be locked to prevent this kind of problem.
Good luck. Let us know if you have more problems.
Message 3 of 4
(2,636 Views)
Hello,

Thank you for your help folks ... very usefully all your advises.

Have a great day!
0 Kudos
Message 4 of 4
(2,614 Views)