I have found out that statically allocated memory in mex files seems to survive between different calls from Matlab (unless the user types “clear mex” or “clear all”). Even if they didn’t, there do exist functions which let you mark stuff as persistent in memory.
Now to the question of mine: I am aware that some OS:es cough can take considerable time to start and stop threads. Would there be some way to let threads live on after a mex function call and be taken right back up at the next call.
The obvious goal would be to gain speed so any answer which gives some other kind of hint how to do this would be acceptable to me too.