LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

memory allocation failed

I need to allocate a 3 dimensional array containing the image data of 100 images.

My array has dimensions of 100 x 1280 x 1024 and contains I16.
According to my calculations this should take up: 100 x 1280 x 1024 x 2 bytes = 250 MB.

I have 1 GB of RAM, of which 750 MB is unallocated when I start my memory allocation.

Labview however fails to allocate memory.

Can anyone tell me why this is?

Using Labview 7.1.1 with Vision 7.1.1

Example below runs, but fills both my pagefile and my memory with about 750MB of data.

0 Kudos
Message 1 of 9
(4,017 Views)
Hello Arend:

That´s  just quite strange, however I can't view your VI for checking it. I have LabVIEW 7.0 so I wonder if you can save it for version 7.0 in order to check it out.



Robst - CLD

Using LabVIEW since version 7.0


0 Kudos
Message 2 of 9
(3,984 Views)
Sure, here it is.
And thanks in advance for any help you can provide.


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

Robst might have a problem with the example, because LV 7.0 has a problem when allocating large arrays from constant values. It doesn't return an error.

LV's automatic memory management is something which is very good for most purposes, but will make life difficult when dealing with structures of this size. One thing to understand about LV's memory allocation is that it requires a contiguous area in memory for everything it allocates. That means it will have to find a vacant area of 250 MB which is hard since the memory gets defragmented.

I don't know why you see a 750 MB consumption on that example. I could understand 500 MB (250 for the wire and 250 for the indicator), but I don't know where the third one comes from.

To do this you will probably need to do this in sections, either working from files or having several arrays which will be smaller each. Keep in mind that making copies in such a case is something to watch out for. If you tell us what you actually want to do, another way might be offered.
 
For more details on this, you should read the LV memory handling white paper found in the bookshelf in the help menu.

___________________
Try to take over the world!
Message 4 of 9
(3,957 Views)
I'm working on a NUC routine for a digital camera.
In order to do this, I get 100 images from the camera with exposure times 1ms - 100ms with steps of 1 ms.
This gives me an array of 100 images of 1280x1024.
Now I want to make dark current curves for every pixel.
I tried doing this by using the get_pixel_value vi from vision in a double for loop.
The result was too slow. It took 30 minutes to determine all the curves.
So I tried to convert all of the images into a 3d-array of 100x1280x1024 dimension.
This conversion only took 20 seconds, and after doing this, determining all the curves only took another 40 seconds.

So this part is oke, but now my labview memory is almost full.
I finally found a vi which forces labview to empty the memory after calling a vi, an it seems to have done the trick.
I'm still puzzeled why labview wants to have a "backup" memory copy in the cache, but I'll have a look at the suggested documentation.

Thanks for your time.
Best regards,
Arend
0 Kudos
Message 5 of 9
(3,937 Views)
Hi Arend,

"I finally found a vi which forces labview to empty the memory after calling a vi"

Could you post that vi?

I'm about to run into the same problem.  I have an application that passes several clusters between VIs and such.  Everything is fine for now but I would like to add a feature which may bloat the size of my clusters and hence my whole program.  We already have several in-house tools made long before my time that use excessive amounts of memory and the lab computers are old and, well, shall we say "memory challenged" to begin with so I've been scrutinizing my use to an obsessive point.  That vi could really help me out.

Thanks so much!

0 Kudos
Message 6 of 9
(3,896 Views)

The VI is called Request Deallocation and can be found in the Advanced>>Data Manipulation palette.

As far as I know, this VI only deallocates the memory allocated for the VI calling it, so it will only help you if you do this the right way.

Note - In general, doing most things "the right way" results in reuse of the buffer and therefore requires no need for deallocation. This should normally only be used in cases of really big data structures where this could be needed.


___________________
Try to take over the world!
0 Kudos
Message 7 of 9
(3,888 Views)
In LV7.1 just loading the VI into memory allocates 250MB of memory. That is because LabVIEW compiler is "smart" enough to realize that the array with all constant sizes can be created at compile time. So it creates the array and store it in the VI dataspace. To outsmart the compiler and avoid the creation of the constant array at edit-time, replace one of the size constant with a control storing the same default value.


LabVIEW, C'est LabVIEW

Message 8 of 9
(3,881 Views)
Thanx for the additional insight in this matter, I really appreciate it.
0 Kudos
Message 9 of 9
(3,843 Views)