- Using fewer workers is one option. It is recommended to have at least 8 GB of memory per worker for Simulink workflows. Please refer to the following link for more information:https://www.mathworks.com/support/requirements/matlab-parallel-server.html
- Limiting the size of the logged data will help. For more details on this topic, execute the following command in the MATLAB R2019b command window:>> web(fullfile(docroot, 'simulink/ug/limit-amount-of-exported-data.html'))
- Using a "postSimFcn" to delete redundant data from the output is another way to control this issue. To learn how to set a "postSimFcn", run the following command in the MATLAB R2019b command window:>> web(fullfile(docroot, 'simulink/slref/setpostsimfcn.html'))
- Use the "Log Dataset to file" option as described in the documentation. For release-specific details, execute the following command in the MATLAB R2019b command window:>> web(fullfile(docroot, 'simulink/gui/log-dataset-data-to-file.html'))
Why does my computer experience high memory usage while attempting to run "parsim" multiple times?
9 views (last 30 days)
Show older comments
MathWorks Support Team
on 18 Sep 2023
Edited: MathWorks Support Team
on 31 Jan 2025
Why does my computer experience high memory usage while attempting to run "parsim" multiple times? My "SimulationOutput" data is replaced every run to manage memory but I still experience high memory usage.
Accepted Answer
MathWorks Support Team
on 25 Jan 2025
Edited: MathWorks Support Team
on 31 Jan 2025
If the program involves running "parsim" several times (in a loop or otherwise), the client in the parallel pool slowly collects data from the workers and then converts it into a "SimulationOutput" object at the end of each simulation run. A good practice to follow here would be to remove the output data of a previous run from memory. However, even then, at a certain point in time, it is possible that the "SimulationOutput" from at least two separate runs exist simultaneously in memory, i.e., the current run's outputs in the function workspace and the previous run's outputs in the base workspace. It is important, hence, to monitor the size of the "SimulationOutput" one is dealing with.
Here are a few workarounds to consider regarding the above issue:
It might seem like the below line of code would also achieve the same goal as the "Log Dataset to file" option:
in = in.setModelParameter('LoggingToFile', 'On')
However, this will not have much of an effect if the Simulink model uses "To Workspace" blocks. These blocks do not support the "Dataset" format, which is the format in which data is stored by the "Log Dataset to file" option. Instead of the "To Workspace" block, the workaround here is to send the output to "outport" blocks along with using the "Log Dataset to file" option as linked above.
Please follow the link below to search for the required information regarding the current release:
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!