MATLAB可用内存,无需清除命令

vol*_*ssa 2 matlab shared memory-management clear parfor

我需要在没有清除命令的情况下使用Matlab释放内存(我在并行工具箱的parfor循环中,无法调用clear);我读的是,例如,

clear v  
Run Code Online (Sandbox Code Playgroud)

我可以设定

v=[]
Run Code Online (Sandbox Code Playgroud)

问题是:使用'= []',我会取消分配'v'的内存,或者只是将v设置为空值,并且先前的内存仍在分配,然后无法使用?谢谢

Pur*_*uit 5

您阅读正确。这是一个示范:

我的计算机现在的内存(清除工作区后,但有一些剩余的东西和绘图):

>> memory
Maximum possible array:            54699 MB (5.736e+10 bytes) *
Memory available for all arrays:            54699 MB (5.736e+10 bytes) *
Memory used by MATLAB:             1003 MB (1.052e+09 bytes)
Physical Memory (RAM):            32695 MB (3.428e+10 bytes)

*  Limited by System Memory (physical + swap file) available.
Run Code Online (Sandbox Code Playgroud)

分配一个十亿元素数组并再次检查内存:

>> x = rand(1e6,1e3);
>> memory
Maximum possible array:            46934 MB (4.921e+10 bytes) *
Memory available for all arrays:            46934 MB (4.921e+10 bytes) *
Memory used by MATLAB:             8690 MB (9.113e+09 bytes)
Physical Memory (RAM):            32695 MB (3.428e+10 bytes)

*  Limited by System Memory (physical + swap file) available.
Run Code Online (Sandbox Code Playgroud)

将变量设置为[]。再次可以使用大多数内存(请注意少量丢失):

>> x = [];
>> memory
Maximum possible array:            54578 MB (5.723e+10 bytes) *
Memory available for all arrays:            54578 MB (5.723e+10 bytes) *
Memory used by MATLAB:             1061 MB (1.113e+09 bytes)
Physical Memory (RAM):            32695 MB (3.428e+10 bytes)

*  Limited by System Memory (physical + swap file) available.
Run Code Online (Sandbox Code Playgroud)