How to completely reset Matlab's workspace?

74 ビュー (過去 30 日間)
Zohar
Zohar 2017 年 9 月 19 日
コメント済み: Walter Roberson 2022 年 9 月 2 日
How can I reset Matlab's workspace (environment) as if I restarted it without actually restarting it (to avoid overhead)? Perhaps specifically to trigger garbage collection?
This is in order to resolve the problem of Matlab degrading and become slower over time, probably due to poor memory management:
  3 件のコメント
Adam
Adam 2017 年 9 月 19 日
clear all
will also remove functions and classes from the cache which may further help to trigger garbage collection (for class objects). It may not though.
Zohar
Zohar 2017 年 9 月 20 日
As I mention in the second link, running the following every iteration doesn't help:
clear classes; clear functions; dbclear all; clear all; pack;

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2017 年 9 月 19 日
編集済み: Jan 2017 年 9 月 19 日
  8 件のコメント
Louis-Philippe Guinard
Louis-Philippe Guinard 2022 年 9 月 2 日
I'm coming back for more.
I'm using parallel processing to analyze many images at once. If I run the code once, everything is fine, but as soon as I run it a second time, I get an error saying 'Out of memory'. This is annoying because technically I have to exit and restart MatLab every time. Moreover, the updated solution Mr. Robertson has provided doesn't seem to work for me. Please also note that I boosted my laptop's RAM to 32Go, 3200MHz (up from 8Go, 2667MHz) expressively for the purpose of running parallel processing.
This means I need to reconnect to multiple workers (one for each physical core I want to use) every time I need to restart the code. Granted, it's still WAAAAAAAAAY faster than analyzing sequentially (which, for me, took more than an hour for five measly images, compared to about 7 minutes for 5 cores) but still it feels unpolished. Any solution to that would be greatly appreciated!
Thanks in advance! :)
LP
Walter Roberson
Walter Roberson 2022 年 9 月 2 日
I suggest using the (newer) -batch option to matlab.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by