Matlab leaking memory?
조회 수: 9 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!