For the very same code memory is not released after a "clear" on Ubuntu but is on Windows

6 views (last 30 days)
Hello, I use matlab R2021b under both windows and ubuntu. There are already topics about this, but this time I noticed that my code was running correctly under windows while it don't work under ubuntu, (ie ubuntu kills matlab without any error message, but when I checked with the "top" command, I saw that the 32 GB of ram was all used) I put clear everywhere in my code, but they are only working under windows and not truly effective on ubuntu. The Ram is saturated under ubuntu (32GB RAM) while it is not under windows (16GB RAM) even though I have half as much RAM on this PC.
Do you have a solution to this problem of memory management of matlab and ubuntu?
  4 Comments
Jan
Jan on 28 Feb 2023
@Dylan: This is a correct observation. Clearing a variable marks the memory as usable on demand, but it is not released. This is more efficient that requesting new memory on demand. As said before, clear is rarely useful in Matlab. An exception is the need to create multiple variable one after the other, which would exhaust the RAM. Then a clearing allows to re-use the memory. But if a function is left, the variables are cleared automatically already and overwriting of existing variables doe s not profit from clearing also.
Dylan
Dylan on 28 Feb 2023
Thank you for the explanation ! What do you propose in order to be able to load a large amount of data, process it, and release memory step by step during the processing when a variable is no more usefull ?

Sign in to comment.

Answers (1)

Steven Lord
Steven Lord on 28 Feb 2023
I suspect that the Out of Memory Killer is what killed MATLAB on your Ubuntu machine. See this webpage for more information and instructions on how to check if my suspicion is correct. I don't believe Windows has an equivalent to the OOM Killer and that's why your code continued to run on Windows.
The Ram is saturated under ubuntu (32GB RAM) while it is not under windows (16GB RAM) even though I have half as much RAM on this PC.
How specifically did you determine this on the two systems?
  3 Comments
Dylan
Dylan on 28 Feb 2023
yes, but there is no graphical output in my case. It is just a big cell of structures and I perform some mathematical operations that's all.

Sign in to comment.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!