Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

how image memory is allocated ??

Hi all,

I'd like to understand how LabVIEW allocates memory for IMAQ images.
I have WinXP (32 bit) and LV 8.5 on a PC with 4Go RAM (only 2Go can be handled by a single app) ; I'd like to know, depending the image size, the maximum of images that I can allocate (8 bits grayscale), here is what I observe :

 - 2000*1000        max 911 images = 1737 Mo
 - 1000*1000        max 1781 images = 1698 Mo
 - 500*1000          max 3414 images = 1628 Mo
 - 100*1000          max 13275 images = 1266 Mo

It is not linearly proportionnal... How can I forsee, based on the image size and "2Go - currently memory used by LV" the maximum number of image that can be allocated ?

Thanks in advance !

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 1 of 4
(3,796 Views)
Hi,

The number is variable and depends on the amount of CONTIGUOUS memory available on your system.
You need at least a block of contiguous memory of the size of the image to allocate so that Vision can allocate the image.
You'll observe that you'll be able to allocate more images when you work with smaller images and the system is able to more easily find a contiguous block of memory than when you work with bigger images. That's why the numbers are not totally linear.
 
-Christophe
 
Message 2 of 4
(3,784 Views)
I am a bit confused...

if I allocate 1000*1000 images in a while loop that runs untill there is an error "out of memory" it goes up to 1781 so that's 1781*1000*1000 = 17.81 Mo
if I allocate 100*1000 images I would expect to be able to allocate 10 times more (17810), you say I should be able to get a bit more, and in fact I can't even reach 14000... Smiley Surprised



We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 3 of 4
(3,774 Views)

Hi, TiTou,

I guess, in general following happened:
Assumed, that you will create 8 bit image with default border (which is 3 by default).

So, if you will create image 1000x1000, then in the memory you will allocate 1024 bytes for each line (because alignment) and border will take additional 6 lines. So, real allocated size is 1024*1006 = 1030144. For 1781 images it will take 1781*1030144 = 1 834 686 464 bytes.

Now you have 100x1000. For this image you will allocate 128 bytes per line. Real allocated space for each image will take 128*1006=128768 bytes. For 14000 images it will take approx  14000*128768=1 802 752 000 bytes. I guess, a bit more - 14200 images or so. But you will never get 17810 images, because image geomethry is different from the first example.

Hint: you can obtain the Line Width with IMAQ GetImagePixelPtr function.

Hopefully it helps,

best regards,

Andrey.

Message 4 of 4
(3,753 Views)