10-05-2016 06:50 PM
Hoping to get some recommendations about removing large variant data from memory. Here is an equivalent representation of my block diagram (I've edited the diagram to remove any IP).
Anways, the issue I am facing is LabVIEW eating up all the available system memory when inside the for loop. The ActiveX object functions I am using require a large variant data to be placed into memory as input to the next function. Running this loop results in LabVIEW throwing an error "-2146959355: Server execution failed" after the memory is full.
How do I prevent LabVIEW from using all that memory? I do not need to keep the variant data, I just need some averaged results after a set number of loops.
Solved! Go to Solution.
10-05-2016 06:57 PM
Can you see what happens if you put those two nodes in a normal (i.e. non-reentrant) SubVI?
If no change, then see what happens if you put a "Request Deallocation" node on the block diagram of that SubVI?
10-05-2016 07:07 PM
Thanks for your reply. I've tried both of those recommendations already. Neither prevents the memory increase.
10-06-2016 01:43 PM
One thing to notice is that writing 30MB in a for loop 50 times shouldn't be using up multiple GB of RAM. This means there must be something else causing your issue.
Is this program running this peice of code as a sub VI within a larger VI or is it calling some other programs?
I would also like to know how much memory LabVIEW itself is using when running this code?
10-06-2016 01:52 PM
Without knowing what your code does I don't know if it's viable, but can you open and close the ActiveX reference every time the loop occurs?
Also, it's a .NET function so it may do nothing, but you can try running a garbage collection:
10-06-2016 11:03 PM
Another thing to note: LabVIEW will not release this memory until the LabVIEW is closed.
30MB was an approximate value. It very well could be larger. 50 x 30MB = 1.5GB so its not far off. LabVIEW memory is increasing by 30-100MB every loop iteration. This is not part of a larger program, I am calling the above code from another top-level VI.
Unfortunately, I can't close the ActiveX object in every loop iteration. I'm not sure how to get that garbage collection invoke noke on my diagram properly.
I've seen in document below that Labview 2013 and earlier (I have 2013) doesn't properly close ActiveX PropertyObject's inside a variant from an ActiveX node. 1) I'm not sure how to determine if that variant has a PropertyObject inside, 2) I tested with the trial version of LabVIEW 2016 but there is still a memory leak.
http://digital.ni.com/public.nsf/allkb/C340060ECAFAA169862573C900723541
Here I have updated my block diagram to be more thorough:
Any further recommendations are greatly appreciated.
10-07-2016 08:18 AM
You've hidden a lot of stuff, I assume for proprietary reasons. But what does this activeX call actually do?
To me is seems like you have an activeX program problem, not a LabVIEW problem.
10-07-2016 01:21 PM
To create the garbage collection node:
Drop an invoke node on the block diagram
Right click it, choose Select Class -> .NET -> Browse
In the Browse window, select "mscorlib" in the top section
In the bottom section of the window, double click on "System" to open a long list of items under it
Scroll down until you see the "GC" option, select it, and press OK
Click the method selector and choose the "[S]Collect()" method
Again, since it's .NET and you're using ActiveX, it seems unlikely to do anything. But you can always try...
10-08-2016 03:31 AM
Thanks everyone for the support. It turns out there was in fact a memory leak in the ActiveX program portion (I don't have any control over that).