‎01-14-2015 09:59 AM
I am making a vi that displays all the images in a directory. Kind of like an enlarged thumbnail viewer. I am looping through the files and populating a 2D array of a picture control. The vi works fine. I am using this as a subvi in a main vi. An executable is being made from the main vi. When I run the executable and check the memory used in task manager, the memory used is a small amount. When I run the subvi and the pictures load, the memory used increases. This is to be expected. However when I close the subvi the memory does not go back to the amount used before opening the subvi.
How do I clear the memory used by my subvi. Attached is the code being used in the subvi.
Thanks
Terry
‎01-14-2015 10:37 AM
Have you tried the "Request Deallocation" Function? I am not positive it would work in this case, but it is worth a try.
‎01-14-2015
12:17 PM
- last edited on
‎05-21-2025
10:59 AM
by
Content Cleaner
If you can load your VI dynamically, the memory will be cleared when you close your subVI reference.
It's very well explained here: https://www.ni.com/docs/en-US/bundle/labview/page/dynamically-loading-and-calling-vis.html
‎01-14-2015 01:24 PM - edited ‎01-14-2015 01:35 PM
Just as a side note, your array operations after the loop could be replaced by a single "reshape array". Probably more efficient and, if done right, you wont get truncation at the decimation operation (as you currently do!) if the number of elements is not an integer multiple of four.
‎01-14-2015 01:33 PM
How are you monitoring memory use? If you're using the Windows Task Manager, this is the normal behavior - LabVIEW grabs memory but doesn't release it back to the operating system, in case it's needed later. This isn't really a problem; if LabVIEW isn't actively using that memory and the operating system needs more free RAM, it will swap the unused memory that LabVIEW allocated to disk (virtual memory).
‎01-14-2015 01:41 PM
@nathand wrote:
How are you monitoring memory use? If you're using the Windows Task Manager, this is the normal behavior - LabVIEW grabs memory but doesn't release it back to the operating system, in case it's needed later. This isn't really a problem; if LabVIEW isn't actively using that memory and the operating system needs more free RAM, it will swap the unused memory that LabVIEW allocated to disk (virtual memory).
That is correct. You should only try to deallocate the memory if you never call that subVI ever again in that same session. If you typically call it again at a later point, it is more efficient if LabVIEW can re-use the allocated memory next time the subVI is called.
‎01-14-2015 03:04 PM
If it still bothers you, try writing a 2D array of images which contains only one image and that image contains only one pixel as the last thing the VI does before it closes. I have not tried this but it might fool LV into thinking you have a very small array.
Lynn