Why would Matlab's `rand(1,1e9)` make 64-bit Windows 7 unresponsive?
<p>When I start a new Matlab session, the <code>rand(1,1e9);</code> command causes my 64-bit Windows 7 to become unresponsive.  That means once every few minutes, it might respond to a mouse click or some such from a few minutes back, but otherwise, I can't even flip between apps, can't invoke the task manager, and if the task manager was running before the <code>rand(1,1e9);</code> command, can't even scroll to Matlab on the Processes tab.  I don't get an out-of-memory message.  Clicking on Matlab's "X" icon to close the app doesn't do anything.  Ctrl-C doesn't do anything, and neither does Break in unison with any 1-, 2-, and 3-key combination of Shift, Ctrl, and Alt.</p>

<p>It might be informative to know that <code>rand(1,1e8);</code> (10x fewer doubles) doesn't cause these problems and finishes in (relatively) no time at all.</p>

<p>The memory info from the <code>memory</code> command is:</p>

<pre><code>&gt;&gt; memory
Maximum possible array:     12782 MB (1.340e+10 bytes) *
Memory available for all arrays:     12782 MB (1.340e+10 bytes) *
Memory used by MATLAB:       674 MB (7.068e+08 bytes)
Physical Memory (RAM):      8070 MB (8.462e+09 bytes)

*  Limited by System Memory (physical + swap file) available.
</code></pre>

<p>On the few occasions in which I can kill Matlab, the OS remains hardly responsive as described above, even when the task manager shows the memory usage go from 7.9GB to nearly zero.</p>

<p>How can Matlab's <code>rand(1,1e9);</code> cause this persistent OS irresponsiveness?  Assuming the problem is memory related, how can I ensure that Matlab plays nicely with the OS (and/or vice-versa) when these limits are being bumped up against?</p>

<p>Please note that this is not a question about how to avoid bumping against the memory limits, as I know I can code around them. It's about how to avoid the loss of control when the limits are bumped up against so that I can decide whether I want to interrupt or kill the operation and/or app.  For example, <a href="http://www.mathworks.com/help/matlab/matlab_prog/memory-allocation.html?refresh=true" rel="nofollow">Matlab's Memory Allocation page</a> shows that 1e9 doubles takes 8e9 bytes, so together with other memory requirements, I'm probably bumping up against the real and swap memory shown above.  No matter if I get an error, or the command simply takes much, much longer, I would still want Matlab to respond to keyboard requests to break. I would also want the rest of the OS to be responsive, including the use of the task manager to kill Matlab in the event that it doesn't respond to a break request.</p>