MATLAB: Does the application’s memory usage steadily increase when using the Image Acquisition Toolbox 1.5 (R14) to log images to disk

diskImage Acquisition Toolboximaqlogloggingmemoryout

I have created a videoinput object using the Image Acquisition Toolbox's VIDEOINPUT function. I then created an AVI-file object using the AVIFILE function, and specified that the videoinput object log data to disk using this avi file. For example:
my_log = 'my_datalog.avi';
aviobj = avifile(my_log);
vid = videoinput('winvideo')
vid.FramesPerTrigger = inf;
vid.LoggingMode = 'disk';
vid.DiskLogger = aviobj;
start(vid)
Since I am logging data to disk and not to memory, I do not expect that my application will run out of memory. However, after a period of time, I receive the following error:
Unable to allocate memory for an incoming image frame. Use help imaqmem to modify the frame memory limit.
Additionally, I can see my memory usage increase when periodically calling the IMAQMEM function.

Best Answer

These memory issues are occurring essentially because images are being captured faster than the machine can encode them with the selected AVI codec and write them to disk. As such, after a period of time, the frame memory buffer overflows.
One option to work around this issue is to reduce the resolution size of the data you are capturing. For a list of the resolution formats supported by your camera, enter the following at the MATLAB Command Prompt:
a = imaqhwinfo('winvideo',1)
a.SupportedFormats
Another option is to use a different codec to compress the AVI-file data, which may ultimately result in less data being written to disk. Note that caution must be taken if this option is used, because most codecs are not designed for real-time compression As such, they may have difficulty "keeping up" with the frame rate. Because of this issue, it is often helpful to use no AVI compression at all.
For information on setting a different codec with your AVI-file, enter the following at the MATLAB command prompt:
doc avifile