Where is the workspace saved?

17 visualizaciones (últimos 30 días)
Patrick Aoun
Patrick Aoun el 16 de Sept. de 2016
Editada: Stephen23 el 16 de Sept. de 2016
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?

Respuesta aceptada

Image Analyst
Image Analyst el 16 de Sept. de 2016
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 comentarios
Patrick Aoun
Patrick Aoun el 16 de Sept. de 2016
Thanks! That definitely explains why my parfor loop is obliterating my RAM...
Stephen23
Stephen23 el 16 de Sept. de 2016
Editada: Stephen23 el 16 de Sept. de 2016
"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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Workspace Variables and MAT-Files en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by