MATLAB Answers

Matlab leaking memory?

1 ビュー (過去 30 日間)
Alaster Meehan
Alaster Meehan 2019 年 9 月 26 日
回答済み: Sai Bhargav Avula 2019 年 12 月 4 日
Below is an attempt at cleaning some memory from Matlab, it seems that "clear all" is giving me less memory.
I am using a custom GUI using the the old figure, not the uifigure, not sure if this would help. Also using some .NET structures, but I am careful about clearing these in my code, and most of those structures are small.
I suspect that some java variables are not being cleaned, most likely when Images are being relpaced on an images axis as this is the biggest memory use.
32GB of memory is a lot to use without any variables in the work space!
Is there a way to clear free RAM without restarting Matlab? Ideally I would like to be able to run a clean up without having to close my GUI or clear my workspace.
>> memory
Maximum possible array: 16540 MB (1.734e+10 bytes) *
Memory available for all arrays: 16540 MB (1.734e+10 bytes) *
Memory used by MATLAB: 33625 MB (3.526e+10 bytes)
Physical Memory (RAM): 32684 MB (3.427e+10 bytes)
* Limited by System Memory (physical + swap file) available.
>> clear all
>> memory
Maximum possible array: 11476 MB (1.203e+10 bytes) *
Memory available for all arrays: 11476 MB (1.203e+10 bytes) *
Memory used by MATLAB: 32313 MB (3.388e+10 bytes)
Physical Memory (RAM): 32684 MB (3.427e+10 bytes)
* Limited by System Memory (physical + swap file) available.
>> clearvars -global
>> memory
Maximum possible array: 10238 MB (1.074e+10 bytes) *
Memory available for all arrays: 10238 MB (1.074e+10 bytes) *
Memory used by MATLAB: 32313 MB (3.388e+10 bytes)
Physical Memory (RAM): 32684 MB (3.427e+10 bytes)
* Limited by System Memory (physical + swap file) available.
>>

  0 件のコメント

サインイン to comment.

回答 (1 件)

Sai Bhargav Avula
Sai Bhargav Avula 2019 年 12 月 4 日
Hi,
I believe this has to do more with the OS and its memory management routines. clear statements can mark the memory being unused, it’s up to the OS to reclaim it. Even if there is sufficient free memory, it is free contiguous memory that is limiting when creating arrays. Once it becomes insufficient it throws an error.
Following the guidelines given in the below link can help you to avoid them.
The above link will guide you through different issues that can cause memory issues and detailed steps to avoid them.
Hope this helps! ,

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

タグ


Translated by