Improving Memory Allocation with NI-IMAQ and the NI PCIe-1429
Overview
NI-IMAQ 3.1.2 has introduced several new features which dramatically improve memory allocation performance for IMAQ acquisitions. These improvements allow users to allocate more memory for an acquisition and substantially increase the recording duration of high speed imaging applications. For example, on a PC with 4GB of RAM installed, it is now possible to allocate almost 2.0GB for a single IMAQ acquisition, out of the theoretical maximum of 3GB of user mode memory. Acquiring at the full Camera Link bandwidth of 680MB/s using the NI PCIe-1429, this represents about 3 seconds of continuous image acquisition.
This document describes the steps necessary to achieve the maximum possible memory allocation and recording duration from your system. The following three steps are required to allocate up to 2.0GB of memory.
Note: These steps are primarily intended for NI PCIe-1429 users who need extended recording duration for high speed applications. National Instruments does not recommend this procedure for most IMAQ applications using other NI image acquisition (IMAQ) devices. In these cases, NI-IMAQ 3.1.2 will still provide significantly greater memory allocation than previous versions.
Table of Contents
Step 1: Physical Memory Requirement
National Instruments recommends installing as much physical memory as is practical in the system. RAM is a relatively inexpensive component of a machine vision system, yet it can have a significant impact on overall system performance. Adding more memory beyond the minimum required for a given acquisition can improve the user experience by reducing the time required for acquisition configuration. Most modern workstation class systems will support at least 4GB memory. Additional memory beyond 4GB will not improve imaging performance, due to a limitation of 32-bit operating systems.
Step 2: NI-IMAQ Attribute
Expanding the amount of memory available for an acquisition requires setting an NI-IMAQ attribute during acquisition configuration. The method for setting this attribute will depend on your development environment. Using this attribute, applications can typically allocate approximately 1.6GB of image buffers, provided enough physical RAM is available and not being used by other applications (minimum of 3GB recommended).
LabVIEW users:
Call the IMG_ATTR_EXTENDED_MEMORY.vi immediately after calling IMAQ Init.vi in your application. See the example attached below.

[+] Enlarge Image
C/C++ users:
To set the extended memory attribute in your application, call imgSetAttribute immediately after opening a session to the interface. This attribute will persist until the interface is closed.
#define IMG_ATTR_EXTENDED_MEMORY (_IMG_BASE + 0x0539)
imgInterfaceOpen (intfName, &Iid);
imgSessionOpen (Iid, &Sid);
imgSetAttribute (Sid, IMG_ATTR_EXTENDED_MEMORY, 0);
....
Step 3: 3GB Operating System Switch (optional)
By default, Windows allocates 2GB of memory to user mode and 2GB to kernel mode. NI-IMAQ acquisition buffers reside in user mode memory and increasing the amount of user mode memory available will increase the number of buffers you can allocate. Some Windows versions provide a boot option that instructs the OS to allocate 3GB to user mode memory. Using this boot option can allow a single application to reach the 2GB per process limit, instead of being restricted by a 2GB total user mode limit. The following versions of Windows support this feature.
Note: Refer to "4GT RAM Tuning" in MSDN Memory Management for more details.
Windows Server 2003 family
Windows XP Professional Edition
Windows 2000 Datacenter Server
Windows 2000 Advanced Server
Windows NT 4.0 Enterprise Edition
The following steps describe how to set the /3GB option on an XP Pro system. The appearance of the dialogs may be slightly different on other Windows versions.
1. Open System Properties dialog and select Advanced >> Startup and Recovery Settings.
2. Select Edit to edit the startup options file manually as shown in Figure 1.
3. Add the /3GB option to the end of the operating system you intend to use.
4. Save and then close the boot.ini file.
5. Close and relaunch the Startup and Recovery dialog to verify the /3GB option is applied.
6. You will need to restart your machine for this setting to take effect.
Note: Although NI-IMAQ is safe with the /3GB boot option, other applications or device drivers could potentially conflict with this mode. Use this option only if you need to allocate more than approximately 1.6GB of image buffers. Using this option, an application can allocate almost 2.0GB of image buffers, provided enough physical RAM is available and not being used by other applications (minimum of 3GB recommended).

Figure 1. Startup and Recovery before /3GB option

Figure 2. Adding /3GB to boot.ini file

Figure 3. Startup and Recovery after adding /3GB option
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
