Error -50352 "Memory Cannot Be Allocated" on LabVIEW

Updated Dec 23, 2023

Reported In

Driver

  • NI-DAQmx

Operating System

  • Windows

Issue Details

I have a LabVIEW program that is returning the Error -50352 "Memory Cannot Be Allocated."  How can I resolve this?

Solution

This issue can occur under different situations. Please refer below to the section that applies the better to your context to resolve the error.

Using the DAQmx driver
Various known issues related to this error message have been corrected starting on DAQmx 19.5. Hence, the first step is to make sure to have the latest compatible version of the DAQmx driver . If having the most recent version of the driver that is compatible with your system did not resolve the issue or if it is not possible to install it because you are using an old version of LabVIEW, refer to the following troubleshooting steps:
 
  • Confirm the DAQmx shipping example programs work properly with your device. This will help determine whether the issue is in the hardware or software.
  • If applicable, connect the hardware to a different slot of your device and check if the error persists.
  • Make sure that you are not trying to start a task that has already been started. Ensure that any calls to DAQmx Start Task.vi are outside of the read/write loop. Also, if using more than one DAQmx Write.vi, try wiring a false constant to the autostart input terminal in LabVIEW (or passing the equivalent parameter using the C interface).
  • Make sure you are not forgetting to "Clear" a task at the end of the program. If this is done, successive runs of the program may use up all of your system's memory, ultimately yielding this error. Ensure that the DAQmx Clear Task.vi is included at the end of the code.
  • When LabVIEW cannot find a large enough contiguous block of memory in your RAM to allocate as a buffer for your sample acquisition. By default, DAQmx automatically configures the AI buffer based on your sample rate, but you can use DAQmx Configure Input Buffer to manually create a smaller buffer.
    • Please see this KnowledgeBase article for more information on how DAQmx allocates buffer size
    • Note: If you create a smaller buffer, make sure that your LabVIEW application can read the samples off the buffer fast enough so that you do not encounter a buffer overflow error (Error -200279).
If the above troubleshooting did not work, you can also ensure that your system has the latest OS updates installed. Running Windows Update Service on your machine and installing updates has been used to successfully eliminate this error in the past. 

Streaming data to a USB drive or SD card from a Real-Time controller
If you are streaming data at a speed that is not supported by either your Real-Time controller or your SD card or USB drive, this error is likely to appear. Try the following troubleshooting steps to resolve it:
  1. Make sure that the application's streaming speed is within your Real-Time controller's specification. The typical data throughput from a Real-Time controller system's memory to a SD card is 40 MB/s and 100 MB/s to a USB Type-C, but please refer to your device specification to double check this information as it can be different for your controller.
  2. If the streaming speed is below your controller's limit, then the SD card or the USB drive might not be capable of receiving data at this speed. Try to reduce the streaming speed of your application and check if the error dissapears or if it takes longer to occur.
  3. If after reducing the streaming speed the error dissapear or takes longer to occur but you still need to stream at a higher rate, use a different SD card or USB drive that you are sure will be able to handle your application's data throughput. You will need to refer to the SD card or USB drive datasheet to check this.