title: Giving more memory to mex programs in Matlab
body: <p>My C mex-compiled files are running out of memory (more specifically, my calls to <code>mxMalloc</code> sometimes return <code>NULL</code>). From a quick calculation I estimate that my files ask <code>mxMalloc</code> for about 500 MB of memory in total (maybe as much as 1 GB), and I run my files on a 64 bit Linux machine with 16 GB of memory running Matlab almost exclusively. Yet, <code>mxMalloc</code> returns <code>NULL</code> quite often.</p>
  
  <p>I guess that that there are several reasons why this could happen (memory fragmentation, etc.), but in any case, 500 MB do not seem to be that much to ask from a 16-GB-memory machine. </p>
  
  <p>I presume that my calls to <code>mxMalloc</code> request memory from Matlab's heap, but am not 100% sure about it ( <code>mxMalloc</code> requests are handled by Matlab after all, and not directly by the OS). So is there a way of increasing my mex file's "heap" size? </p>
  
  <p>Thanks</p>