Pratul Pratul - 5 months ago 15
Linux Question

Specify output directory for MATLAB crash dump files

I am running MATLAB on Linux with limited storage space in my home directory (

). When MATLAB crashes, it places the crash dump files (
) in my home directory. I would like to change the directory in which these files are placed. What is the best way to do this?


You need to specify the MATLAB_LOG_DIR environment variable. MATLAB will use this to store all crash dumps.

From a related MATLAB Central discussion:

If you have set the environment variable $MATLAB_LOG_DIR, that's where we'll write the crash dump file. Otherwise, look in $HOME on UNIX, or in $TEMP, $TMP, $WINDIR, and finally C:\ (in that order) on Windows. The file will be named "matlab_crash_dump.$pid" where $pid is the process ID of MATLAB.

You can either do this within your .bashrc file

export MATLAB_LOG_DIR=/custom/dir

Or within MATLAB itself prior to running any commands (or within your matlabrc file)

setenv('MATLAB_LOG_DIR', '/custom/dir')

If you need to test this, the following simple mex file will cause a crash resulting in a crash dump file.

#include "mex.h"

void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
    /* Access beyond the length of prhs */
    size_t x = mxGetM(prhs[6]);