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: 

ActiveX call returns large about of date, how to delete from memory?

Solved!
Go to solution

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).

block_diagram.jpg

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.

usage.jpg

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.

0 Kudos
Message 1 of 9
(3,361 Views)

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?

0 Kudos
Message 2 of 9
(3,348 Views)

Thanks for your reply. I've tried both of those recommendations already. Neither prevents the memory increase.

0 Kudos
Message 3 of 9
(3,344 Views)

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?

0 Kudos
Message 4 of 9
(3,309 Views)

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:

Garbage collect.png

0 Kudos
Message 5 of 9
(3,307 Views)

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:
block_diagram2.jpg

Any further recommendations are greatly appreciated.

0 Kudos
Message 6 of 9
(3,289 Views)
Solution
Accepted by topic author abeaver

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.

0 Kudos
Message 7 of 9
(3,271 Views)

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...

0 Kudos
Message 8 of 9
(3,259 Views)

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).

0 Kudos
Message 9 of 9
(3,242 Views)