09-27-2013 01:35 AM
Hi there,
I´m having trouble using the C# API to DAQmx. I attached a sample program to demonstrate the way I use the API.
The problem I´m facing is that the application needs more and more memory over time. My assumption is that a memory leak occurred somewhere. I tried different ways to call the API and read the methods documentation, but I still didn´t manage to get around that issue.
Any help is aprechiated!
PS: A brief description of my program:
-Create Tasks (DI, DO, AI, AO)
-Add Channels (DI, DO, AI, DO)
-StartTasks
-Start Thread and cyclic read/write current values to/from local variables
Solved! Go to Solution.
09-30-2013 07:02 AM
Hi niwaly,
Do you clear the task after you're done measuring (DAQmxClearTask)? (I don't have a license for Visual Studio)
Do you also experience the issue if you try an example delivered with the driver?
Examples are located here:
C:\Users\Public\Documents\National Instruments\NI-DAQ
What versions of VS and DAQmx are you using?
Kind regards
Heinz
09-30-2013 08:03 AM
Hi Heinz,
thanks for your answer.
The versions I use are:
NI-DAQmx Device Driver 9.2.3f1
Measurement Studio DotNET
Common 9.0.40.362
NationalInstruments.DAQmx 9.2.40.82
I dont clear the task because I want to measure as long as the dll is loaded. I reuse the Task subsequent measurments. The pendant to C++ Clear Task is Dispose, I expect that to make the Task no longer usable for measuring.
In the meantime I assume the line
double[,] readValues = _inputReader.ReadMultiSample(InputMedianValueCount);
as the cause of the leaking memory.
I didn´t try the examples, so I can´t tell at the moment if they cause the same problem.
Kind Regards,
niwaly
09-30-2013 09:04 AM
Hi niwaly,
I strongly recommend you to try the examples. This way you can be sure the issue is not the driver itself and you can debug your application. It may also give you a clue on how to proceed.
If you do not have any examples in the folder i mentioned, you did not install the driver with c# support added during installation procedure.
Here are some more examples:
http://www.ni.com/white-paper/6999/en
Kind regards
Heinz
10-01-2013 06:55 AM
Hi,
it seems to be working now: adding the line
_inputTask.Timing.SampleQuantityMode = SampleQuantityMode.FiniteSamples;
together with avoiding to start and stop the task manually did the trick. As assumed in the last post the analog input was the part that caused the leak. There is at a first glance no memory leaking after about 60 minutes.
I still don´t understand why the first variant (start/stop) wasn´t working.