Solution
The NI-DAQmx driver allocates and de-allocates memory when a task is created and when a task is cleared, respectively. For example, if you have a
DAQmx Create Task.vi inside a while loop, a new task will be created on every iteration of the while loop. If there is nothing limiting the speed of the while loop, tasks will be created so quickly that LabVIEW will quickly run out of memory.
You can prevent this by using the
DAQmx Clear Task.vi. By clearing every task we create, we are allocating and deallocating memory correctly. Only tasks with unique names can be created so an easy way to prevent accidentally creating tasks in a loop is to name them. The
DAQmx Create Task.vi will output an error if it tries to create a task that already exists.