I'm writing a program for a project that is becoming more and more complex. Among the others, it calls a function to take pictures (using the webcam package), performs some data extraction from it and then returns this data. This operation involves the communication with 2 devices (an IR camera and a 3d printer) and takes tipically 0.08 seconds. However, in my program this operation must be repeated for a lot of iterations (sometimes it can be 2000) and the program has many different cycles involving this process. I once got a "out of memory" warning in matlab command window with a general consistent slowering of this function (up to 6 s!!!).
function Result_Imaging = AcquisitionIR(IR_cam,Pixels)
frameIR = snapshot(IR_cam);
Result_Imaging = struct
Is it possible that the pictures I'm taking remain saved in memory even if I'm taking them in a function, performing some calculations and not saving them? I tried adding a
clearvars -except Result_Imaging
at the end of the function but for, for example 100 frames, doesn't make a lot of difference.
The RAM is 16 GB.