LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Inexplicable memory allocate error with DAQmx Write (error -50352)

Hi,

 

 I'm experiencing a problem with memory allocation. It seems as if there's a memory leak somewhere, as my program runs fine for a random number of times (between 10-20), then randomly stops with the "Memory Cannot Be Allocated" error. I've read the KB article on it: http://digital.ni.com/public.nsf/allkb/00A43B6D38EB768E86257537000120BB

 

The error occurs at my "fast_analog_input" task, at the DAQmx Write VI, which is right before the DAQmx Start Task VI sequence (see attached daqmx_io_new2.vi).

 

I just don't understand why the program runs successfully multiple times before the error gets thrown. When I look at the Windows Task Manager, the memory LV uses doesn't increase, the pagefile doesn't increase, the system memory being used doesn't increase, the cached memory doesn't increase, the free memory doesn't decrease, etc. However, I still get the memory error. 

 

I clean up all my tasks, I close all the files I read, etc. LV uses a total of around 400MB of memory, and I have 4GB of ram on 32-bit Vista with virtual memory increased to 3GB. I'm using the most recent drivers (DAQmx 8.9, LabVIEW 8.6). 

 

Attached are my relevant VIs. Sorry that they're so large. daqmx_io_new2.vi has the various DAQmx Write/Read stuff in it, and this is where the error occurs and where most everything happens. crazy_virtual_channel_setup_new.vi set ups all of my tasks and channels. crazy_cleanup_new.vi clears the tasks at the end.

 

Also, it's worth noting I had a similar problem with my analog input task, but I solved it by changing the sample type to Continuous Samples as opposed to Finite Samples. I can't do this with my output tasks though because I need to have the Wait Until Done VIs at the end before the tasks are cleared. 

 

If I need to supply anything else or be more specific please let me know. Also, sorry that the code is too specific for anyone to run; you would need a certain TDMS file to do so. However, if anyone can take a look and spot whatever might be leaking memory, I'd really appreciate it.

 

Thanks!

0 Kudos
Message 1 of 3
(3,074 Views)

Hi Djaunl,

 

You're correct that your code is quite complex, which makes it hard to troubleshoot.  In lieu of simpler code, I would verify that:

 

1: You're not starting a task repeatedly in a loop (trying to Start a task that has already been started can cause this error)

2: Try clearing a task instead of just stopping it.  This will release reserved memory immediately. 

3: Reduce your buffer size

 

To really troubleshoot this code, we're going to need cleaner code.  Let's replace all TDMS reads with Sinewaves so that any user can run the code.  We should also temporarily remove the queue structure to focus on the DAQmx code.  I would love to help you out with this, but I need code that executes.

 

 

-John Sullivan
Problem Solver
0 Kudos
Message 2 of 3
(3,047 Views)

Hi Djaunl,

 

In addition to John's suggestions, note that increasing the size of the user virtual address space to 3 GB also decreases the size of the kernel virtual address space from 2 GB to 1 GB. This may be amplifying the effects of kernel virtual address space fragmentation and causing the DAQmx buffer allocations to fail. If this is the case, deleting the IncreaseUserVa parameter from your boot configuration data store might help alleviate the memory allocation errors (at the expense of user virtual address space).

 

Brad

---
Brad Keryan
NI R&D
0 Kudos
Message 3 of 3
(3,039 Views)