LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Memory not de-allocated when main VI stopped

I have a program which builds a data array and while running I can see it using increasing system memory as the array grows.

 

However, when I stop the program, it does not de-allocate memory back to the baseline for the program-open state.  It can be seen to de-allocate a few hundred megabytes but not back to the baseline.  So, if the program is run repeatedly, it eventually runs out of memory.

 

I had thought that stopping a program should automatically de-allocate memory and initiate other "garbage collection" functions.

 

What can I do to see that this memory is properly de-allocated at Stop?

 

I have looked at Labview_Memory references but I don't seem to have the Labview vocabulary to find what I am looking for.

 

You can ask me to post the code if you like but it is big, messy, not mine and grew like Topsy the Elephant over ten years.  Also, it won't run unless you have two DAQ cards installed.

0 Kudos
Message 1 of 7
(2,828 Views)

What version of LabVIEW are you using?

You can try the "Request Deallocation" node to deallocate the memory.

Please refer the attachment to find the node.

 

Regards,

Muthuraman S

Regards,
Muthuraman
0 Kudos
Message 2 of 7
(2,824 Views)

It looks like I need to use DAQmx Clear Task.vi rather than DAQmx Stop Task.vi after the data acquisition loop runs.  In code that I write, I generally create tasks in MAX and then reference them.  The main VI in this case uses DAQmx CreateTask.vi to define the tasks and therefore requires a different memory cleanup method.

 

Could someone explain the difference between Stop Task and Clear Task because the Help is not helpful in describing which one should be used in different cases?

0 Kudos
Message 3 of 7
(2,823 Views)

I did find references to the Request Deallocation function but there are a number of warnings that there should be other ways to deallocate memory that are more efficient because it "can cause LabVIEW to reallocate space repeatedly".

0 Kudos
Message 4 of 7
(2,820 Views)

Start Task and Stop Task can be used for finer control timing of tasks.  Look at how Continuous Measurement or Finite in loops works.  Clear Task erases it and should release the memory.


--Using LV8.2, 8.6, 2009, 2012--
0 Kudos
Message 5 of 7
(2,817 Views)

Replacing Stop Task with Clear Task did not seem to solve the problem.  I am still getting residual memory.  I did look up Request Deallocation again and it only applies to sub VIs.  All my data collection and array-filling take place in the main VI.

0 Kudos
Message 6 of 7
(2,814 Views)

I discovered that an analog output task was starting and stopping itself inside the data acquisition loop, removing that task stopped the rapid allocation of gigabytes of memory which was not de-allocated when the program was stopped.  There is still some residual memory use build-up but it is on the order of kilobytes and acceptable.

 

Obviously, I am still not clear on what kind of tasks can be allowed to "judge for themselves" when to start and stop and those cases where they need to be explicitly started and stopped.  For the time, I think explicitly is the way to go for everything.

 

I consider this problem solved.  I appreciate the assistance of those who responded.  In retrospect, posting the code might have helped but it took me half an hour to find the tasks and I knew what I was looking for.

0 Kudos
Message 7 of 7
(2,811 Views)