How it's possible that Matlab 2018b uses a lot of memory after the execution of a mex, even if I close Matlab completely?

3 views (last 30 days)
After the execution of C code in simulink, using the coder ceval function and linking all the c sources and libraries (I'm using MOSEK optimization libraries) Matlab seems to keep the memory in use even if I complitely close it (exit Matlab). Clear mex and clear all commands are ineffective. No error signals are displayed by matlab at any point. What can I do to solve this issue.

Answers (1)

Federico
Federico on 15 Jun 2019
Edited: Federico on 15 Jun 2019
I can say the same thing happens to me. I believe it is due to the memory management in MOSEK (the mex files), in MATLAB, or both. According to MATLAB help it says "clear mex does not clear locked MEX functions or functions that are currently in use." and I suspect this is what is happening to us. Even after the program finishes (MATLAB still open), and you clear all variables and mex files, the memory is held there not released. In my case the memory keeps accumulating until MATLAB crashes completely when I'm doing a loop. The issues I have only show up in Linux though.
The only way to deal with this is to contact the developers of MOSEK to improve their memory management of their mex files and/or MATLAB developers who could help us clear memory directly from the command line, but haven't given us that option (or have done a poor job at it).

Categories

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

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!