Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How come I don't get error -1074396159 from IMAQ Configure Buffer.vi in edit mode, but do when the application is compiled as an executable?

I have an LabVIEW 8.2.1 application that scans image data from a camera link line scan camera and works perfectly in the development mode. But when i complied the application the IMAQ Configure Buffer.vi throws a -1074396159 error (Not enough memory for requested operation) when it goes to configure the image buffer.

 

The image is fairly large (8928 x 14,272 grey scale), but it works fine in development. Is it possible that LabVIEW allocates memory for this, yet Windows won't?

 

Getting this app into an exe is the last thing i have to do to get this project launched, any help would be greatly appreciated!

 

Terrell

 

0 Kudos
Message 1 of 6
(4,117 Views)

Thanks for the link. What i get from that is i can go through and shave any memory hogs out (which i've already had to do just to make the thing work) or that I'm screwed if i want to make an executable.

 

It would also mean that LabVIEW must allocate memory for itself and separate Windows memory for running VIs.

 

 

0 Kudos
Message 3 of 6
(4,098 Views)

Terrell,

 

The answer is a bit complicated and the link provided previously is not completely accurate. It is likely just luck as to why one works and the other doesn't. The development and run-time environment should allocate memory in essentially the same ways. Basically, 32-bit apps have a maximum of 4GB of virtual memory space total. This is used not just for storing user data like images, but also all the DLLs and other resources the application uses must all share this space. On a default Windows 32-bit setup, this is actually only 2GB because the kernel traditionally owns the upper half of that memory address range.

 

Secondly, once something has been assigned an address, it generally cannot be moved unless it is first free'd and then re-allocated. What this means is that the 2/4GB of address space tends to get fragmented quite a bit. When you are allocating your 128MB image it must occupy a contiguous piece of virtual memory (not physically contiguous, just virtually). Many times the memory space is so fragmented that getting multiple large chunks of this size is hard of not impossible. What I image might be happening is just the slight differences in the built-app versus running within the development environment is changing the memory layout slightly and causing such that maybe there aren't enough big blocks still free.

 

There are a couple of things you can do to try to help. The first would be getting the tool here:

VMMap http://technet.microsoft.com/en-us/sysinternals/dd535533.aspx 

 

This nice tool lets you see the virtual memory map for a process. You can see how many blocks of memory are free and how big they are if you play with the sorting options. This will let you confirm what you are seeing.

 

Additionally, as I alluded to above, there is a way to increase the amount of virtual memory available to a 32-bit process from the default 2GB to either 3 or 4GB. The latest versions of LabVIEW are compiled with the /LARGEADDRESSAWARE flag that tells them that they can handle the whole 32-bit address range. If you boot your 32-bit system with the /3GB switch any such apps will now have 3GB of address space. Additionally, if you run such apps on a 64-bit OS, those apps will now have 4GB of virtual memory. This can help the amount of large free blocks immensely. You can look in VMMap to see how much memory a running application has access to to see if your built app has access to the same amount of memory in total as the LabVIEW development environment.

 

Lastly, the next option would be to consider moving to a 64-bit version of LabVIEW. With LabVIEW 2009 64-bit you effectively have a virtual unlimited memory address space and this becomes a non-issue. You'll have to pair that with the 2009 versions of Vision Acquisition and Vision Development Module and run on a 64-bit OS of course. 

 

Hope this helps a bit,

Eric 

Message 4 of 6
(4,086 Views)

Eric,

Thanks for your detailed post to this thread. It gave me some things to try but unfortunately, the only thing that worked was to reduce the size of the image. 

 

Some thing to note in case anyone else reads this is that the 3GB switch only works in LV versions 8.5 and newer. I was running 8.2.1 and updating my application would have been a big pain.

 

Terrell

 

PS: Sorry for the long delay in re-posting.

0 Kudos
Message 5 of 6
(3,955 Views)

teager wrote: 

Some thing to note in case anyone else reads this is that the 3GB switch only works in LV versions 8.5 and newer. I was running 8.2.1 and updating my application would have been a big pain.


Hi Terrell,


As I mentioned in my previous post, the LARGEADDRESSAWARE flag is in the binary's image header and is typically emitted by the linker when the application is compiled. As you found out, LV 8.5 is likely the first release that added this flag into the installed binary image.

 

However, you can certainly adjust this flag in the binary yourself if you like. As long as the code doesn't do tricks that truncate the upper bit of 32-bit pointers (this is fairly rare...) you can likely enable this flag yourself on an existing binary (such as LabVIEW.exe). If you'd like to try this, you could use the editbin utility installed with Microsoft's Visual Studio (any edition): 

editbin /LARGEADDRESSAWARE

You can find more details here: http://bilbroblog.com/wow64/hidden-secrets-of-w0w64-ndash-large-address-space/

 

Eric 

 

 

 

0 Kudos
Message 6 of 6
(3,951 Views)