Hi Simone,
I'm sorry I won't be able to help much without any reproducible behavior... Computers have sometimes behaviors that are completely irrational...
There might have been some change on your system, leading to Matlab having less contiguous memory to allocate large variables. You can check the size of the largest variable that Matlab can allocate at the bottom of the Brainstorm preferences window, or directly with Matlab function memory().
You could also check the memory usage while your script is running by opening the resource monitor of your OS.
I haven't checked if this still works with recent Matlab versions, but previously it was also possible to have a very detailed report on the memory allocations with the Matlab profiler:
https://undocumentedmatlab.com/blog/profiling-matlab-memory-usage
https://www.mathworks.com/help/matlab/matlab_prog/profiling-for-improving-performance.html
Note that Brainstorm may keep in memory some temporary objects for faster opening/processing, and this might fill up the memory progressively. You can force unloading all the subjects, the equivalent of clicking on the the cross at the top-right corner of the Brainstorm window, by calling:
bst_memory('UnloadAll', 'Forced');
After this advanced debugging, let me know if you think there are issues with the memory management in scripts.
Cheers,
Francois