MATLAB Answers

DAQ toolbox memory leak

12 views (last 30 days)
Gary Wolf
Gary Wolf on 19 Apr 2016
Edited: Andrei Ursache on 7 Dec 2017
I've been using without problem the Data Acquisition toolbox with a NI PCIe-6363 acquisition card. I now need to acquire repeatedly large number of points (~1-10e6 from 1 analog input and 2 digital inputs) and this has proved to be a problem with the toolbox. While it does work, every call for acquisition (startForeground function) increases the memory used by Matlab by few Mb (~10% of the data size to acquire), and after a while gets > 10 Gb memory and Matlab stops. Just doing in a for loop startForeground + the memory function shows clearly that each call leaks some memory, and no "clear" can release that memory.
Update 1: It appears the memory leak is only in the presence of digital inputs. If they are replace by analog input, then there is no issue, though this is not a viable solution as the DAQ acquisition rate cannot be as high then.
Any help is appreciated! Thanks.

  3 Comments

Vinod
Vinod on 23 Apr 2016
What version of MATLAB are you using? Please contact technical support with reproduction steps.
Tao Cui
Tao Cui on 31 Mar 2017
I also have this issue with NI in daq session. When digital channels are presented in the session and when the task is started in background, memory keeps growing and eventually Matlab crashes with out of memory error. If there are only analog channels, everything will be fine.
The version I have is R2015b. It has been a while since this post, could you let me know if you found a solution.
Gary Wolf
Gary Wolf on 31 Mar 2017
Sorry, I could not find a solution to this issue (also with R2015b).

Sign in to comment.

Answers (2)

Tao Cui
Tao Cui on 25 Apr 2017
Edited: Tao Cui on 25 Apr 2017
The root cause to this problem is the handleDataAvailable method in "AsyncIOInputChannel.m" of daq toolbox's NI interface part. It is even clearly labeled by Mathwork developers in the comment on line 134: "!!! Bug, this only handles results from a single task". Not sure if this will be fixed in their future version.
What happened is when there are both digital card and analog card, or when there are both input card and output card running in a session in background mode, there will be two tasks running in asynchronous mode handled by this method. However, this method cannot handle two tasks properly, hence cause memory problem.
Not necessarily an answer, but I hope this info at least can help others or Mathwork developers to patch this bug.

  0 Comments

Sign in to comment.


Andrei Ursache
Andrei Ursache on 6 Jun 2017
Edited: Andrei Ursache on 7 Dec 2017
This is fixed in MATLAB R2017b.
A workaround is attached to this bug report .

  0 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!