LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to release all resources (all memory) used by a subVI once it as returned to its caller VI?

Solved!
Go to solution

I am currently working on a data analysis application in which we have “out of memory” issues.

 

I have implemented all the "best practices" in the code with limited success.

 

The application does not use the best architecture to handle large data sets but it was the fastest development path to meet some of our deadlines. With the data set sizes we are currently processing, I had hoped to get away with it, and we did for a while!

 

Presently, the data being analyzed is completely loaded from binary files into a waveform array. The data set represents about 110MB of memory: 262144 samples x 52 channels x 8 bytes per double precision floating point value.

 

The memory issues started to appear when several file export options we added to the application. At that point, I realized that big chunks of memory were reserved and never being released after calling different functions (CSV file export, binary file export etc…) sequentially with the data set.

 

I have been searching for a way to deallocate ALL memory used by a subVI after its execution but I was not successful to date.

 

I have tried the following:

  • Request Deallocation VI (very little effect)
  • Tried to set the VI’s call setup to “Reload” (no effect)
  • Tried calling the VI by reference (no effect)
  • Tried calling the VI by reference as an async process (no effect)

I am including some test Vis to demonstrate want I am talking about.

 

Main.vi is a small VI which calls the Function1.vi and Function2.vi upon a button press by the user.

Function1.vi is a VI which generates an array of 2MB and writes it to disk. No inputs and no outputs, except to disk.

Function2.vi same as function 1 except it generates a 4MB array.

 

1 - When starting Main by double-clicking on it, it starts to run and when all LabVIEW background loading is complete, the amount of memory taken by LabVIEW stabilizes at around 95MB (from task manager).

2 - When the Function 1 button is pressed, memory used by LabVIEW rises to 220MB (an increase of 125MB from step 1).

3 - When the Function 2 button is pressed, memory used by LabVIEW rises to 487MB (an increase of 267MB from step 2).

4 - When the Function 1 button is pressed again, memory used by LabVIEW drops to 417MB (a decrease of 80MB from step 3).

5 - When the Function 2 button is pressed again, memory used by LabVIEW rises to 487MB (an increase of 80MB from step 4).

Steps 4 and 5 repeat if the function buttons are pressed again.

 

At this point, LabVIEW is taking about 400MB more memory compared to when Main had not call the Funcrtion1.vi and Function2.vi.

 

Is there any way to release all resources (all memory) used by a subVI once it as returned to its caller VI?

 

Thanks for any help!

 

Michel Lanthier

 

 

Download All
0 Kudos
Message 1 of 15
(5,332 Views)

Hi,

Try This, think will help You

Only configure in Main.vi subVIs paths. and inside subVIs give file path wher will be stored date

With Best Regards

 

Certified LabVIEW Architect (CLA)
Download All
Message 2 of 15
(5,293 Views)

While i see through your vi's, what version of LV are you using.?

There is this block that will help you release un-used memory allotted to a VI available on LV 2012 & above.

Quick search for "Request Deallocation" or find it in the Application Control Pellet > Memory Control > Request Deallocation.

 

 


Regards.
Digant Shetty (LV 18.0)
AE, Combined Digilog Systems Pvt. Ltd.

CDSPL LOGO.pngAlliance Partner.png

0 Kudos
Message 3 of 15
(5,284 Views)

I am using LV 2013, service pack 1 (13.0.1f2, 32-bit)

 

Michel

0 Kudos
Message 4 of 15
(5,252 Views)
Solution
Accepted by topic author Michel_L

For LV2013

Certified LabVIEW Architect (CLA)
Download All
Message 5 of 15
(5,241 Views)

Michel,

 

     I'm assuming you do not know LabVIEW, and haven't viewed any of the LabVIEW Tutorials such as the ones listed in the upper right hand corner of the Forum home page.

 

     Here are some observations:

 

  • Function 1 and Function 2 are the same function.  They create an array of data parameterized by a Size and a Content, and the results are written into a TDMS file with a specific File Path.
  • Write this function with the following inputs:  File Path, Data Size, Test Value, and Error In.  Wire these to the left-hand 4 connectors.  Wire Error Out to the bottom right.
  • The function should not use an Express VI (they are wasteful of resources), and should not use Dynamic Data.  Use the TDMS functions from the File Palette.  [Why are you using TDMS?  Have you thought about the File Format?].
  • The Error Line should be used to sequence your functions within this sub-VI.
  • In your Main, get rid of the Stacked Sequence!  Once you have the Error Line, you can simply line up Function 1 and Function 2, sequence them with the Error Line, surround each with a Case Statement guarded by your two Booleans, and there's your program.

I'm guessing that having only a single function and getting rid of the Express VI and Dynamic Data will have a dramatic effect on your memory allocation.  Give it a try, tell us how it went.

 

Bob Schor

0 Kudos
Message 6 of 15
(5,231 Views)

Thanks Hachya. This can probably be a solution for me.

 

Let me add one more thing: what if I needed Function 1 and Function 2 to receive some input parameters?

 

Michel

 

 

0 Kudos
Message 7 of 15
(5,197 Views)

@Bob_Schor wrote:

Michel,

 

     I'm assuming you do not know LabVIEW, and haven't viewed any of the LabVIEW Tutorials such as the ones listed in the upper right hand corner of the Forum home page.

 

     Here are some observations:

 

  • Function 1 and Function 2 are the same function.  They create an array of data parameterized by a Size and a Content, and the results are written into a TDMS file with a specific File Path.
  • Write this function with the following inputs:  File Path, Data Size, Test Value, and Error In.  Wire these to the left-hand 4 connectors.  Wire Error Out to the bottom right.
  • The function should not use an Express VI (they are wasteful of resources), and should not use Dynamic Data.  Use the TDMS functions from the File Palette.  [Why are you using TDMS?  Have you thought about the File Format?].
  • The Error Line should be used to sequence your functions within this sub-VI.
  • In your Main, get rid of the Stacked Sequence!  Once you have the Error Line, you can simply line up Function 1 and Function 2, sequence them with the Error Line, surround each with a Case Statement guarded by your two Booleans, and there's your program.

I'm guessing that having only a single function and getting rid of the Express VI and Dynamic Data will have a dramatic effect on your memory allocation.  Give it a try, tell us how it went.

 

Bob Schor


Bob,

Thanks for your reply.

 

I do have some experience with LabVIEW.

 

Main.vi, Function1.vi and Function2.vi are just an example I built so that I can find a way to get rid of ressources used by a subVI after its execution, in the scope of a much larger application.

 

I never use Express Vis unless I need to do something quick and dirty. However, in this case, they provided me with an easy way to illustrate the problem I am trying to fix, that is, releasing memory ressources after a memory hungry subVI executes.

 

0 Kudos
Message 8 of 15
(5,187 Views)

Your example is very poor, because the code only depends on diagram constants and is thus precalculated at compile time (folded). The data is part of the code! As long as the main VI is in memory, the subVIs will be in memory.

 

Please show us the actual code that is causing you memory problems.

 

Just from looking at your code, I suspect that you are a beginner so there are problably tons of inefficient constructs. Most likely, your memory problems are non-issues.

 

Don't use stacked sequences. Stay away from dynamic data and express VIs.

0 Kudos
Message 9 of 15
(5,183 Views)

Welcom Michel!!!

If You will need help write me.

With Best Regards

Hrachya

Certified LabVIEW Architect (CLA)
0 Kudos
Message 10 of 15
(5,172 Views)