LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to release memory after VI terminated

Solved!
Go to solution

A data was collected once a time in a loop, and appended to a data array. The collection was finished after the loop ends and a data array was built. At the end the data was written to a file. The program was terminated naturally. I assume all the variables are cleared from memory after termination, but it was not. If I run the program twice without close it, I am having a newly collected set of data appended to the old ones, which was created in my last run. A third set was appended if I run it once more.

 

I just want to keep the latest run as my data and I don't want to close the program to set all my parameters of similar runs. How to do it?

 

An example file is attached.

 

Thanks.

0 Kudos
Message 1 of 13
(3,441 Views)
Solution
Accepted by hrwang

You need to wire an empty array constant to the initializer terminal (bottom terminal) of the feedback node.

=====================
LabVIEW 2012


Message 2 of 13
(3,436 Views)

Thanks. Pretty new to labview. I was thinking that way too. But I couldn't find such a thing from the function panel. There are alot of things are experience based.

0 Kudos
Message 3 of 13
(3,429 Views)

Not sure if this is what you mentioned. It didn't work. See attached.

0 Kudos
Message 4 of 13
(3,425 Views)

@hrwang wrote:

But I couldn't find such a thing from the function panel.


No need to find it. Simply right-click the initializer terminal and select "create constant".

 

Also:

  • "Write to Spreadheet file" has a "transpose" input. If you wire a boolean true constant to it (right-click..create constant..change to true), there is no need to transpose first.
  • What is the purpose of the stop button?
  • You are missing the last generated points because you are tapping the array after the feedback node. Wire before it.
  • Since X is spaced equally, all you need is a waveform graph.
  • Since you loop completes so fast, all you need is autoindexing at the right loop boundary and graph once at the end after the loop. (nno need for feedback nodes)
Message 5 of 13
(3,421 Views)

@hrwang wrote:

Not sure if this is what you mentioned. It didn't work. See attached.


The data lives in the feedback node, not in the indicator. Wire the empty array to the bottom of the feedback node. Delete these local variables!

0 Kudos
Message 6 of 13
(3,418 Views)

It worked. Thanks. Is there anyway to empty the array after the program ends?

0 Kudos
Message 7 of 13
(3,417 Views)

@hrwang wrote:

It worked. Thanks. Is there anyway to empty the array after the program ends?


Why? There is no need to do so. The memory will be release when you close LabVIEW. Also, when you save the VI, the data is not included.

 

Assuming that your x-vaules are actually not spaced equally (even though they currently are), here's what you could do.

0 Kudos
Message 8 of 13
(3,415 Views)

There are difference between program is terminated and closed. The memories are released if the program is closed. The variables are not released if the program is stoped and run without being closed. You can try to run the VI attached twice without close it, and check the result of second run. 

0 Kudos
Message 9 of 13
(3,378 Views)

The code was just a demonstration of what I want. I wan to generate a data from a device and put it into an array, modify the array use some math and get an updated array. So I really need the array in the loop and get graph updated at each loop step.

 

Thanks for instructions.

0 Kudos
Message 10 of 13
(3,367 Views)