clearing memory during function runing

Hi, im runing a function that uses a lot of memory and sometimes the function stops because there is not enough memory. is it possible to clear variables during running in order to free some memory?
thank you

Réponses (2)

Walter Roberson
Walter Roberson le 20 Nov 2013

0 votes

You can clear variables in the current function's workspace, or in the base workspace, or global variables.

4 commentaires

Dany
Dany le 20 Nov 2013
i am doing it (clearvars C F TDF t X allTG Names tmp tf) but ufortunatly it does not help me, still heaving the same memory problem. any thing else i can do, except putting more memory to my computer?
Walter Roberson
Walter Roberson le 20 Nov 2013
Probably not. However, in some cases it works to store calculations to a file, PACK, and then restore the file and continue.
Laurent
Laurent le 20 Nov 2013
But PACK cannot be used from within a function, so it will not solve memory problems during running of the function.
Walter Roberson
Walter Roberson le 20 Nov 2013
Correct. But sometimes it makes sense to "checkpoint" your current state, return back up some levels, clean up memory, and then restart from the checkpoint.

Connectez-vous pour commenter.

E. Bisson
E. Bisson le 20 Nov 2013
You can use the clear command.
clear variable1 variable2

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Produits

Tags

Question posée :

le 20 Nov 2013

Community Treasure Hunt

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

Start Hunting!

Translated by