MATLAB Answers

MatLab DAQ session causes memory leak when running in background mode with digital channels

6 views (last 30 days)
Daniel Hall
Daniel Hall on 10 Apr 2015
Edited: Andrei Ursache on 7 Dec 2017
I'm using the Session-based DAQ on MatLab 2013a with a NI PCI-6229 card. I have found that if I include digital channels (InputOnly or Bidirectional Input setting) for reading on/off signals, and I run the session in Background mode (startBackground), then the memory usage by MatLab steadily increases steadily. Stopping and resetting the session does not release this memory, nor does deleting the session.
I can attach more detailed code if necessary, but I've found that the simplest way to replicate this is to create a session with one analog and one digital channel (the analog channel clocks the digital one), have the DataAvailable callback simply plot the data ( plot(event.TimeStamps, event.Data) ), and run it.
Has anyone else encountered this issue and know a way around it?

  1 Comment

Tao Cui
Tao Cui on 31 Mar 2017
I also have exactly this issue with session based daq using NI. 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 works fine.
The version I have is R2015b. It has been two years since this post, has anyone came up with solutions or workarounds. Or if Matlab or NI noticed this issue.

Sign in to comment.

Answers (2)

Scott Whitney
Scott Whitney on 27 May 2015
Daniel, I don't know if you are still having this problem, but I was also. In my case I have 4 analog output channels and 4 analog input channels. I have a listener for the analog input to log the data, and a listener to queue up more data for the output. The sample rates for the analog input and output were the same (100kHz). What I found was that I was queuing up the data faster than it was being transmitted out of the card. I had wanted to queue up the data in 1 second increments. The listener was calling back the queuing function after only 10000 samples were output, instead of 50000, so it kept on filling up the output buffer until matlab ran out of memory.

  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!