LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

increasing memory - systematic failure in the vi?

Solved!
Go to solution

Hi,

I use a Framegrabber DLL to read a analog video stream. When the VI runs about 6 hours LabVIEW shows an error message "memory is full".

When the VI is running and I have a look to the memory usage in the task manager I see that the memory is increasing continously.

 

I suppose the bug is inside the while-loop but I can't fix it.

It can also be a problem of the DLL but I don't know where to start. Can it somthing to do with references?

 

 

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

Yes, it's absolutely to do with references.

 

Any time you create a reference, or a reference is returned from a method/property node, that reference needs to be closed. It's a common trap that people usually do the first one, but forget about the second one. For example, in the while loop you have a reference returned from 'LockNextImage' and also 'ToBitmap' which are generated within the loop but aren't closed within it so those references are left hanging.

 

The desktop execution trace toolkit is a very handy tool for checking for references that are left open when you finish executing. When you stop the VI, you'll see a whole load of yellow rows for references that weren't closed during execution.

 

You obviously need to be careful not to close a reference before you are finished with it (e.g. closing the reference from 'ToBitmap' should be done after the PictureBox) but you'll soon get an error if you close it early.

 

You should prioritise closing any references that are obtained within any loops - that's where you'll have a memory leak. If you open a reference once and forget to close it it generally isn't too much of a problem but it is if you do it repeatedly every millisecond!


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 2 of 9
(3,548 Views)

Hi Sam_Sharp,

 

I understand the problem with the references, but I need the referenc outside the while for other function calls like ImageFormat or Device->Stop.

How can I solve this?

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

I didn't say you need to close all references inside the loop - only the ones that are generated inside the loop.

 

I've highlighted all of the places (I think) in your screenshot where you've generated/obtained a reference:

2015-11-23_13-54-03.png

 

I count 11 places where references are obtained (there will be more because of arrays of references) and only 3 close references. Inside the loop, after you've used the LockNextImage and ToBitmap references you can then release them (i.e. place them after the ConvertImage/UnlockNextImage and the PictureBox nodes) as they are not used outside of the loop.


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 4 of 9
(3,534 Views)
Solution
Accepted by topic author Michael65589

Please have a look to the screenshot.

I have closed the references. Is it what you mean?

 

Framegrabber_LabVIEW_1.jpg

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

It's messy (folded wires), but yes, it looks like that would work.

 

Like I said - you can test it yourself by using the Desktop Execution Trace Toolkit - turn off all of the options except the one about references and then run / stop your application. It will show you all of the orphaned references.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 6 of 9
(3,522 Views)

Yes okay it works. I saw it with the memory usage.

Many thanks.

 

Have a nice week.

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

As a small tweak i'd place that Live Image terminal before the loop and use a feedback node of it until you exit the loop and use its close ref, instead of doing it every loop.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 9
(3,505 Views)

@Michael65589 wrote:

Yes okay it works. I saw it with the memory usage.

Many thanks.

 

Have a nice week.


Feel free to Kudos my post or mark one as the solution if they have been helpful 🙂


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 9 of 9
(3,487 Views)