Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

ImageToArray causes memory overflow

I am using Imaq ImageTo Array for converting a greyscale image into a 2D matrix of grey values. However, I notice that each time I call this VI, the amount of free memory reduces which eventually results in memory overflow. How can I de-allocate the memory without destroying the image? That is, I cannot use ImageDispose function! I am using LabVIEW 8.6 with IMAQ 4.1 on Win XP SP3

 

0 Kudos
Message 1 of 17
(5,052 Views)

Ali Ghaderi -

 

Per the documentation, you must call imaqDispose() on the array that's returned (not the image) to free it.  This should get rid of the memory leak.

 

Greg Stoll

Vision R&D

National Instruments

Greg Stoll
LabVIEW R&D
0 Kudos
Message 2 of 17
(5,049 Views)

Thank you for the response. I have alerady read this somewhere else. However, I do not quite understand this. Since the only ImaqDispose function I find in the functions palette, gets rid of the image :mansad:

 

So I guess my question is how do one uses imaqDispose() on the array? 

0 Kudos
Message 3 of 17
(5,035 Views)

Ali Ghaderi -

 

imaqDispose() is used to dispose images as well as other memory allocated in our DLL (such as report structures), so it will work on both.

 

You should be able to call it on the array just like you would on an image, so if you have the code:

 

char* arrayData = imaqImageToArray(image, IMAQ_NO_RECT, NULL, NULL);

/* Processing goes here */

imaqDispose(arrayData);

 

and after the last imaqDispose() call the array will be destroyed and there will be no memory leak.

 

Greg Stoll

Vision R&D

National Instruments

Greg Stoll
LabVIEW R&D
0 Kudos
Message 4 of 17
(5,025 Views)

Greg,

 

apparently I am a new comer who has no clue on what you are talking about. You are referring to a text base programming function which I do not see how I can implement in LabVIEW with the icon imaqDispose in the functions palette. I start to wonder if my installation is right. Can you send me a hint?

 

regards

Ali 

0 Kudos
Message 5 of 17
(5,024 Views)

Ali -

 

Oh, sorry, I thought you were talking about our CVI interface for some reason.  My mistake!

 

You shouldn't have to do anything special to free the memory - LabVIEW should take care of that for you.  Can you post a screenshot of your code?

 

Greg Stoll

Vision R&D

National Instruments

Greg Stoll
LabVIEW R&D
0 Kudos
Message 6 of 17
(5,020 Views)

Hey,

 

I'd like to bump this, as I'm having the same issue.

 

I'm doing my master thesis right now and need to utilize the Harris Corner Finder. Using Labview this works great, however i stumbled upon a problem. Everytime I call the VI, the allocated memory increases by 1-5MB. I have broken it down to the VI with the corner finder in which I use the ImageToArray-VI.

 

As this phenomenon makes up around 300-500 MB per Picture, my program is useless after the 4th picture...

0 Kudos
Message 7 of 17
(4,980 Views)

Der_schorsch -

 

Can you post a screenshot of your code?

 

Greg Stoll

Vision R&D

National Instruments

Greg Stoll
LabVIEW R&D
0 Kudos
Message 8 of 17
(4,972 Views)

Are you sure you're not accidentally leaking memory by creating extra IMAQ images and not destroying them? Is it possible the array data from ImageToArray is being saved into a growing shift register in your sub-VI that is never cleared?

 

I tested the below VI and did not see any leak:

 

-Eric 

Message Edited by BlueCheese on 01-15-2009 11:09 AM
Message Edited by BlueCheese on 01-15-2009 11:10 AM
0 Kudos
Message 9 of 17
(4,970 Views)

 

Hey,

 

I'm already home, but I will post the VI as soon as I am back in the lab tomorrow morning.

0 Kudos
Message 10 of 17
(4,963 Views)