MATLAB Answers

close and restart matlab ? or another way out?

251 views (last 30 days)
AA on 6 Feb 2018
Commented: Jan on 12 Jun 2019
I have a code that is quite computationally and memory-wise intensive and given the RAM(64Gb) I have, I can utilize it for my purpose and get my work done. My code does some kind of optimization, so I need to run my code again, but even after upon performing these operations
clear all;
close all;
I observe that MATLAB does not release the RAM fully, and only upon restarting, it does. I have some idea that this is a known problem with MATLAB, but I am just curious, has there been any new development that can help? I have R2017a running on Ubuntu16.04
Secondly, I am OK with re-starting and launching a new session, but running these commands
system('matlab &');
does not help. I see a startup screen, but there is no new window. Also, removing the '&' from above launches a new window but the previous one remains and the RAM is not freed.
Can anyone please help me with this?
  1 Comment
Jan on 12 Jun 2019
The question is older, but perhaps someone is interested: Starting a new Matlab session should work with the shown command. Without the "&" the system command does not return before the called process is finished.
How do you observe that Matlab uses some memory? There might be some locked M functions or mlock'ed Mex functions. And even if the operating system displays, that Matlab "uses" some memory, this does not necessarily mean, that this memory cannot be used for processing. This could be e.g. a cache from the last disk access - I'm not sure if this is displayed as belonging to the process or to the operating system. Such "occupied" memory is free'd immediately, if it is needed again.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!