10-08-2024 07:05 PM
Hello, I am running into an issue where the runtime of each loop iteration increases when only opening and reading .mat files using the "MATLAB" data plugin. Attached is a VI replicating what we are seeing in a much larger analysis VI. It continuously opens the same .mat file and calculates the runtime. Opening task manager shows the memory slowly increase while the VI runs. As default, the VI's graph shows the results I got after stopping the while loop after 2002 iterations.
I have read that not closing the Read Data Storage can lead to memory leaks, which I have tried separating the Read and Close Data Storage parts with a Flat and Stacked Sequence Structure, but I keep getting the same error message (Error -2553). I don't understand why the error occurs since it is my understanding that these structures should execute the Close after Reading. Error also happens in the final iteration of a For and While Loop when the Close is outside the loop. Attached is a VI with these cases that I have tried.
I also attach a single .mat file to use to test.
Any help on this issue would be appreciated.
10-11-2024 10:51 AM
That is a very large amount of references you open, i'm not surprised it'll eventually lead to problems. Open once outside any loop.
10-11-2024 12:48 PM
We have to open several thousand .mat files and analyze them all, so there is no other way but to open them inside a while loop as it iterates through all found inside a directory.