LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

camera memory leak

Hi,
 
I am using a camera to check calibration status in some automated testing. But the camera locks up every half hour or so because of a memory leak - it seems that the IMAQ dispose is not clearing all of the memory allocated to IMAQ create. I am using 1 IMAQ dispose for every IMAQ create (i think!) but by monitoring task manager i can see the PF Usage slowly increase to 1.8GB when the camera stops working & the whole system needs to be rebooted.
By using breakpoints  I have verified that the memory is allocated at Imaq create (7MB), memory usage remains the same until IMAQ dispose, where some memory is released (4MB), but not all.
 
I am using Labview 7.1. Attached are a couple of the sub VIs i use which have a leakage problem: CheckCalFinished_N_flashcode_nosub.vi & CheckAllLEDsPresent.vi
 
I haven't used the vision stuff before so maybe i am using it incorrectly. Has anyone else experienced this memory problem & what can be done to stop it?
 
I'd really appreciate any help/experience
 
Thanks
Fi
0 Kudos
Message 1 of 16
(4,326 Views)

Without having run your VI (as I do not use IMAQ for USB) I the following problem in your code:

Your VI "CheckCalFinished_N_flashcode_nosub.vi" reads from a the local variable "Image" when disposing the image. This is a race condition in LabVIEW - you should not assume that the local variable is valid: The reading from the local variable might execute before the indicator received the value from IMAQ Create.
Do not use the local variable - use the wire that comes from IMAQ Create.

This might already solve your problem. At least I hope this was helpful.

0 Kudos
Message 2 of 16
(4,310 Views)
Hey Fi,
 
I looked at your code and it looks like you are only setting up one buffer for your IMAQ USB acquisition. I could only pinpoint a couple things that you can look into . First, I saw that you are using a local variable for your image in the CheckCalFinished_N_flashcode_nosub.vi. Have you tried just using the image data type wire? Something else that I saw was that you are using a Vision Assistance generated VI to perform some processing. Have you tried to use the regular VIsion VI's instead? Also, what version of Vision are you using currently? I am concerned that the leak might be in the image processing and not the acquisition. Have you tried reducing what is in your code, to simplify it so that it is just the image acquisition? And if you can simplify the code more, do you still see the problem? If you run a simple USB IMAQ example program, do you see the leak? Try to narrow down your code to find exactly what is causing the leak. From there, we can figure out what is causing the leak.
 
I hope this helps. Please let me know if you have any questions or concerns. Thanks, and have a great day.
 
Regards,
DJ L.
0 Kudos
Message 3 of 16
(4,308 Views)

Hi DJ & Guenter,

Thanks very much for your feedback 🐵

Using the Grab.vi included in the IMAQ for USB driver library ie as simple as it can get, the problem is still there.

If the VI is run repeatedly the PF Usage in task manager creeps up by approx 6MB every time it is run until the PF Usage in task manager reaches 1.9GB when it returns -1074396024 occurred at USB Grab setup.vi which i imagine is saying its run out of memory.

                                          1st time       2nd time      3rd time          4th time

After Camera Enum

After USB Init

After USB Grab SetUp

After Imaq Create

After USB Grab Acquire

After USB STop

AFter USB Close

After Imaq Dispose

 

0 Kudos
Message 4 of 16
(4,300 Views)

Hi DJ & Guenter,

Thanks very much for your feedback 🐵

Using the Grab.vi included in the IMAQ for USB driver library ie as simple as it can get, the problem is still there.

If the VI is run repeatedly the PF Usage in task manager creeps up by approx 6MB every time it is run until the PF Usage in task manager reaches 1.9GB when it returns -1074396024 occurred at USB Grab setup.vi which i imagine is saying its run out of memory.

                                           1st time       2nd time      3rd time          4th time

After Camera Enum

After USB Init

After USB Grab SetUp

After Imaq Create

After USB Grab Acquire

After USB STop

AFter USB Close

After Imaq Dispose

 

0 Kudos
Message 5 of 16
(4,299 Views)

Hi DJ & Guenter,

Thanks very much for your feedback 🐵

Using the Grab.vi included in the IMAQ for USB driver library ie as simple as it can get, the problem is still there.

If the VI is run repeatedly the PF Usage in task manager creeps up by approx 6MB every time it is run until the PF Usage in task manager reaches 1.9GB when it returns -1074396024 occurred at USB Grab setup.vi which i imagine is saying its run out of memory.

                                            1st time       2nd time      3rd time          4th time

After Camera Enum

After USB Init

After USB Grab SetUp

After Imaq Create

After USB Grab Acquire

After USB STop

AFter USB Close

After Imaq Dispose

 

0 Kudos
Message 6 of 16
(4,302 Views)

Hi DJ & Guenter,

Thanks very much for your feedback 🐵

Using the Grab.vi included in the IMAQ for USB driver library ie as simple as it can get, the problem is still there.

If the VI is run repeatedly the PF Usage in task manager creeps up by approx 6MB every time it is run until the PF Usage in task manager reaches 1.9GB when it returns -1074396024 occurred at USB Grab setup.vi which i imagine is saying its run out of memory.

                                             1st time       2nd time      3rd time          4th time

After Camera Enum

After USB Init

After USB Grab SetUp

After Imaq Create

After USB Grab Acquire

After USB STop

AFter USB Close

After Imaq Dispose

 

0 Kudos
Message 7 of 16
(4,302 Views)

Hi DJ & Guenter,

Thanks very much for your feedback 🐵

Using the Grab.vi included in the IMAQ for USB driver library ie as simple as it can get, the problem is still there.

If the VI is run repeatedly the PF Usage in task manager creeps up by approx 6MB every time it is run until the PF Usage in task manager reaches 1.9GB when it returns -1074396024 occurred at USB Grab setup.vi which i imagine is saying its run out of memory.

                                              1st time       2nd time      3rd time          4th time

After Camera Enum

After USB Init

After USB Grab SetUp

After Imaq Create

After USB Grab Acquire

After USB STop

AFter USB Close

After Imaq Dispose

 

0 Kudos
Message 8 of 16
(4,302 Views)

OOps - sorry - leant on the wrong key - sent before finished

 

Hi DJ & Guenter,

Thanks very much for your feedback

Using the Grab.vi included in the IMAQ for USB driver library ie as simple as it can get, the problem is still there.

If the VI is run repeatedly the PF Usage in task manager creeps up by approx 6MB every time it is run until the PF Usage in task manager reaches 1.9GB when it returns -1074396024 occurred at USB Grab setup.vi which i expect  is saying its run out of memory.

 

Task manager reports PF Usage (MB):

                                          1st time       2nd time      3rd time          4th time

After Camera Enum                              472              477                 485

After USB Init                      469             472               478                483             

After USB Grab SetUp       473              481              486                 492

After Imaq Create                473             479               484                490

After USB Grab Acquire      475              481               486                492

After USB STop                   475              481              485               492

AFter USB Close                 473              478               484               490

After Imaq Dispose              473              478               484               489

 

so it seems the memory is being allocated/used during USB Grab SetUp which contains only a library node calling a function from ImaqDirectShowDll. And then never being cleared by USB stop or close.

I guess there is not much to be done about that?

Thanks again - Have a good day

Fi

0 Kudos
Message 9 of 16
(4,298 Views)
Hey Fi,
 
Thanks for pointing out the memory leak that you are having to us. Others have had similar leaks before as well. I have attached a simple example that someone else tried to get rid of the leak with. The example is called Grab3.VI. Try it out to see if it also gives you a leak.
 
I hope this helps at least a little bit. I do have to mention that the NI-IMAQ for USB driver is not officially supported, so the leak might not be fixed in the near future. Maybe you could try using a different USB camera to see if it also gives a leak. Last, there is always the NI-IMAQ for IEEE 1394 driver for Firewire cameras, and/or the NI-IMAQ driver with a framegrabber. These are other options that you have that will be officially supported.
 
Regards,
DJ L.
0 Kudos
Message 10 of 16
(4,272 Views)