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

@altenbach wrote:

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.


I am sorry but I think your comments are not constructive. I think you missed the core of want I am trying to find here: How to release all resources (all memory) used by a subVI once it as returned to its caller VI?

I cannot send the actual code as it is proprietary.

Message 11 of 15
(2,303 Views)

@Michel_L wrote:

@altenbach wrote:

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.


I am sorry but I think your comments are not constructive. I think you missed the core of want I am trying to find here: How to release all resources (all memory) used by a subVI once it as returned to its caller VI?

I cannot send the actual code as it is proprietary.


You can not.

LV hanldes all memory allocation and in the interest of performance, once allocated, it is never released until the VI goes idle. That is why your attempt to release didn't make much difference. The VIs were still reserved to run.

 

If you follow Christian's advise to " Stay away from dynamic data and express VIs." your memory demands will be reduced and become a non-issue.

 

If you really want to try and return the memory (an exercise in futility) then the sub-VIs can be opned dynamically, called and the closed WITH the Release memory VI inside of them, and as long as that VI is actually closed (ie. not in memory after being closed) the memory may be released. I say may beause the actual behaviour can change between LV versions.

 

I have resently parsed 2.7Gig tab-delimeted files and if I had used Express VIs and dynamic data types, I would have never have completed that project.

 

If you want to learn more gory little details about memory, try clicking on my avatar, and exploring my tag clouds.

 

For what it is worth,

 

Ben

 

 

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

Michel_L wrote:

I am sorry but I think your comments are not constructive. I think you missed the core of want I am trying to find here: How to release all resources (all memory) used by a subVI once it as returned to its caller VI?
I am fully aware of what you are trying to do. It is not constructuve to posts examples that are flawed and do not represent the actual problem code.
Typically it is unproductive to release memory of a subVI, just to reallocate it again at the next call. And the way your example is constructued, you are most likely calling it again with the same amount of data at a later point.
If the memory increases with each call, you have a memory leak that needs to be investigated. It has nothing to do with the way LabVIEW allocates/deallocates memory. You are trying to solve the wrong problem. You need to solve the memory leak, nothing else. Did you read the help for  the "Request deallocation" function? It has very (very!) limited usefulness.
Instead of telling us how you want to do something, tell us what you are trying to do from a larger perspective. Most likely there are simple solutions that don't have any memory issues. (first step, as already mentioned: don't use dynamic data and express VIs!).

 

0 Kudos
Message 13 of 15
(2,286 Views)

For the benifit of everyone, I am including my latest findings.

It seems that opening a reference to a VI (using a strictly typed constant reference to the VI, not a static VI reference), calling the VI by reference then closing the VI reference does the trick of cleanup memory.

In any case, this has drastically reduced memory usage in my application.

In the case where the VI would be called in a loop, this slows down execution but in the case of rarely called VIs, this is very helpfull.

Please see the attached commented VI.

Michel

 

Download All
0 Kudos
Message 14 of 15
(2,235 Views)

@Michel_L wrote:

For the benifit of everyone, I am including my latest findings.

It seems that opening a reference to a VI (using a strictly typed constant reference to the VI, not a static VI reference), calling the VI by reference then closing the VI reference does the trick of cleanup memory.

In any case, this has drastically reduced memory usage in my application.

In the case where the VI would be called in a loop, this slows down execution but in the case of rarely called VIs, this is very helpfull.

Please see the attached commented VI.

Michel

 


Thanks you for letting us know that still works.

Ben

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