If you have something like this:
TaskHandle h;
double *array;
loop // there are lots of ways to write a loop...
{
DAQmxCreateTask(&h);
...
array = malloc(sizeof(double)*1000);
DAQmxReadAnalogF64(... array, ...);
DAQmxStopTask(h);
DAQmxClearTask(h);
}
Every time through the loop an array of 1000 doubles is allocated, but not freed. So every iteration you use another 8000 bytes of memory.
But if you do something like this:
TaskHandle h;
double array[1000];
loop // there are lots of ways to write a loop...
{
DAQmxCreateTask(&h);
...
DAQmxReadAnalogF64(... array, ...);
... Do something with the data ...
DAQmxStopTask(h);
DAQmxClearTask(h);
}
then you are not allocating new memory inside the loop.
In your post, you have DAQmxReadAnalogF64(... readArray(0) ...). I guess you're not using C. Is that Visual Basic? How do you create readArray? My pseudo-code above is based on C.
John Weeks
WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com