Where is the workspace saved?

조회 수: 14 (최근 30일)
Patrick Aoun
Patrick Aoun 2016년 9월 16일
편집: Stephen23 2016년 9월 16일
Pretty straightforward question I guess. Where is the workspace held, in my computer? Is it on the RAM, on the hard drive, or a combination of both?
Is any form of "workspace management" useful? Such as clearing unused variables, or avoiding to keep a lot of huge variables loaded at the same time?

채택된 답변

Image Analyst
Image Analyst 2016년 9월 16일
The workspace is saved in RAM memory. You can also save it to disk to a mat file if you call save(). The main functions for cleaning up are clc, clear, close, and delete. Each of those has several options so check them out in the help. One way to clean up most stuff is
clc;
close all force;
clear all;
clear global;
You can make a shortcut on your toolbar called "Clean up" to do all that. It's often recommended to make such a button by Mathworks trainers.
  댓글 수: 2
Patrick Aoun
Patrick Aoun 2016년 9월 16일
Thanks! That definitely explains why my parfor loop is obliterating my RAM...
Stephen23
Stephen23 2016년 9월 16일
편집: Stephen23 2016년 9월 16일
"Is any form of "workspace management" useful?"
MATLAB intelligently looks after memory, allocating and freeing it up as needed. Good programming practices (such as writing functions rather than scripts, and keeping data together as much as possible) make explicitly clearing data unnecessary. In a few edge-cases this memory management might do something unexpected, but generally you should just leave it up to MATLAB.
If you have some very large arrays and need to clear them otherwise you will run out of memory, then by all means do so. Just keep in mind what the clear documentation says: "Calling clear all, clear classes, and clear functions decreases code performance, and is usually unnecessary." You might like to read about clearvars, which is more useful than clear for clearing variables.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by