For the very same code memory is not released after a "clear" on Ubuntu but is on Windows
6 views (last 30 days)
Show older comments
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
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.
Answers (1)
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
Bruno Luong
on 28 Feb 2023
Some graphical outputs can be source of memory leak and it is out of reach by clear command.
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!