From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to deallocate memory used by the labview program?

Hi,

 

I have bulit a large application in labview 2012 that uses a couple of subvis, local and global variables, some uninitialized shift registers (functional global variables) and some c++ and .net dlls as well. When I open my application the memory usage shown at Windows task manager is around 1.4GB. After running the application and enabling all processes used in the application, the memory usage goes up to 1.55GB but when i stop the application, memory is never released/deallocated until i close the application plus exit labview. Can you suggest how to deallocate this memory? and how can i use the request deallocation function for this application? labview help says i have to place it inside a subVI for which i want to deallocate memory. But i have a lot of subVIs used in my application. I tried placing it in the top level VI and called it after stopping all processes but it didn't work... I am also closing references to all of the .net dlls at the end. Any workarounds??

 

Thanks

0 Kudos
Message 1 of 8
(4,894 Views)

1.4 GB when opening the application without doing anything???? That seems somehow very bad programming!

 

The 0.15GB that get added from runtime are peanuts in comparison. Most likely it is consumed by the uninitialized shift registers. They hold on to whatever memory object your write into them until you overwrite it with another (possibly empty, think zero lenght array for instance) memory object explicitedly yourself or the VI gets unloaded which only happens at the end of an execuable unless you load the VI dynamically and make sure no other VI includes the VI in its hierarchy.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 8
(4,868 Views)

Well there is this function.

 

http://zone.ni.com/reference/en-XX/help/371361J-01/glang/request_dealloc/

 

But I've never seen a real application need it.  Without seeing the code it is hard to say for sure but I agree with rolfk "bad programming". 

0 Kudos
Message 3 of 8
(4,840 Views)

1.4GB Smiley Surprised   Even one MMORPG server with 2.000 players won't waste that amount of memory o:

 

Request Deallocation wont help in this case. You should learn how the LabVIEW memory management works before create one memory eater Smiley Very Happy.

Here's one whitepaper:  http://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/vi_memory_usage/

0 Kudos
Message 4 of 8
(4,830 Views)

rolfk and rest: Remember, it could be what the windows task manager shows. That will include all windows and programs memory, not just LabVIEW.

So a memory use of 1.4 GB for ALL program use when a LabVIEW program is loaded is not that big.

 

And a increase of 150 MB should not give any problems.

Why do you think you need to deallocate 150 MB?

Message 5 of 8
(4,796 Views)
Yes 1.4GB includes windows and programs memory plus labview... this is not the memory usage for just my labview application. I was not sure that after reaching 1.55GB, the next time I run the application will it add this 150MB of memory consumption to 1.55GB or is it going to reuse this memory? I tried re running it but it doesn't go beyond 1.55GB.. so I guess my problem has been resolved... thanks guys
0 Kudos
Message 6 of 8
(4,743 Views)

sandee wrote:

When I open my application the memory usage shown at Windows task manager is around 1.4GB. After running the application and enabling all processes used in the application, the memory usage goes up to 1.55GB but when i stop the application, memory is never released/deallocated until i close the application plus exit labview.


You already got some good advice. One thing that was not clear was how you are measuring memory. Since the task manager is capable of showing the memory used by LabVIEW alone (you simply need to look elsewhere), and you said that the memory gets released when you exit LabVIEW, you gave the impression that the 1.4GB was the LabVIEW portion.

 

OK, so a couple of hundred MB used by LabVIEW is really nothing to worry about. Are you running into memory or other performance problems? What are the symptoms?


sandee wrote:

I have bulit a large application in labview 2012 that uses a couple of subvis, local and global variables, some uninitialized shift registers (functional global variables) and some c++ and .net dlls as well.


We really need to see some code. It is very well posssible that you have a lots of unecessary data copies in memory due to sloppy programming. How big are the data structures? Do you use local variables for big data structures? What does the program actually do?

 

0 Kudos
Message 7 of 8
(4,715 Views)

@SunJab wrote:
Yes 1.4GB includes windows and programs memory plus labview... this is not the memory usage for just my labview application. I was not sure that after reaching 1.55GB, the next time I run the application will it add this 150MB of memory consumption to 1.55GB or is it going to reuse this memory? I tried re running it but it doesn't go beyond 1.55GB.. so I guess my problem has been resolved... thanks guys

Well that wasn't clear from the description. 1.4GB for Windows 8 isn't that spectacular even with no special apps loaded.150MB in th LabVIEW app is sort of excessive (I don't think I have ever written an application that used so much memory for more than brief moments during analysis) but then I still use often techniques that were mandatory in times when the entire computer had to work with 8MB of RAM.

 

And yes LabVIEW usually holds on to memory once it requested it from the OS, but is very good in reusing it in subsequent runs.

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 8
(4,695 Views)