After Allocating a Large Variable and Crashing, MATLAB is Forever Slow

27 ビュー (過去 30 日間)
Richard 2013 年 12 月 30 日
コメント済み: Christian Dandre 2020 年 1 月 31 日
I was playing around with variable allocation sizes to see how it effected my RAM allocation. Another words, looking at a third party memory stats program I would allocate a vector with 1 billion entries and see how much RAM that required.
When I got to allocating 4 billion entries, my entire computer froze. I didn't have a problem with this, I was expecting it to happen at some point. After restarting however, MATLAB seems to be permanently broken. It gets stuck in the busy state upon startup for at least a minute every time. When I try to save a new script, I get weird behavior like the file never being saved even though MATLAB makes me believe it has been. I have tried deleting the AppData\Roaming\Mathwords\R2012b folder but it has no effect. Are there other folders or files like this that I can try removing?
I would like to know the cause of this, but above all I would like to know how to fix this. There must be a way to get MATLAB fixed without having to re-install. Can anyone help?
  6 件のコメント
Angga Lisdiyanto
Angga Lisdiyanto 2016 年 6 月 11 日
Same problem here...
I was set maxheap in the RunWeka.ini for Weka become 4000m. It is because of my Weka is always OutOfMemory for Machine Learning's training. Then the Weka run normaly without OutOfMemory message.
But after it, my Matlab become very slowly and the accuracy of training data if very decrease... It is weird...
Please help....
Christian Dandre
Christian Dandre 2020 年 1 月 31 日
I'm running Matlab R2016b. The code I run normally takes around 1.5 hrs to complete using 4 cpus in parallel processing mode. 3 days ago everything froze up, not just Matlab but the whole operating system (Windows 7 Professional 64-bit) - very unusual.
Had to force a manual reboot. Windows started to reconfigure during start-up. Matlab was slow to start-up. Lots of apps were slow to start and overall everything was generally unresponsive
I re-ran my Matlab code and which froze after interrupting runtime at break points. Other apps were slow to respond also. Matlab froze just before completion at about the time it usually writes Excel files and Matlab data files. Had to manually reboot the machine again.
I repeated the process of re-starting the operating system, opening and closing Matlab, but none of these seemed to work. Windows Explorer confirmed that no new results files had been created from the previous run. I manually rebooted once again.
Then I saw a Java update appear which I proceeded to install. Everything has been fine since then!


回答 (6 件)

Yair Altman
Yair Altman 2014 年 1 月 1 日
編集済み: Yair Altman 2014 年 1 月 1 日
Several possibilities spring to mind:
  1. Your antivirus is running wild ( link1, link2, link3 )
  2. You are using a CVS (code-versioning system) that is ill-configured
  3. You use a remote Matlab license server that is unreachable, or you experience license manager lockouts for some reason, or you're using a mis-configured license file or LM_LICENSE_FILE environment variable
  4. You have clashes with other software that uses the same FLEXnet license manager as Matlab ( link1, link2 )
  5. You have mapped drives that are disconnected for some reason but Matlab doesn't know this
  6. You have a very long Matlab path
  7. You have defined a function somewhere on the Matlab path that has a name which overrides some internal Matlab function
  8. Your Matlab installation is critically fragmented on disk (=> run a defragmetation utility)
  9. You are using a toolbox that is ill-configured (e.g., symbolic toolbox)
  10. You are running Matlab via an X-server or SSH
  11. You have disabled toolbox caching in the global Matlab preferences
  12. You have defined numerous workspace variables
  13. You have numerous files loaded in the Editor
  14. You have multiple open figure windows
  15. You are using SELinux without setting the allow_execheap flag (so JIT is disabled)
  16. You are using a vast number of Windows fonts
  17. You are using unnecessary web-proxy auto-discovery
  18. You have insufficient physical RAM to run Matlab, thereby causing extensive disk thrashing
To isolate things, start Matlab with no startup.m file and with only the default MathWorks path (i.e., remove your folders from the path). If it's now ok, then start adding user paths until you find the culprit. If it's not ok, try reinstalling Matlab from scratch.

Walter Roberson
Walter Roberson 2013 年 12 月 31 日
I would start by deleting matlab.prf out of prefdir . See http://www.mathworks.com/help/matlab/matlab_env/preferences.html#bsoa5yg-1 before starting MATLAB. Then start it, and when you get a prompt, command
rehash toolboxreset; rehash toolboxcache
Another thing I would check would be whether the slowdown is in a network connection at MATLAB startup time. That might be for license checking purposes; there is also something unknown that can require a network connection at startup time in some versions (some kind of authentication ?).
If you are having network problems, one thing to try is to open up your firewall for a moment and see if MATLAB starts faster (remember to close it afterwards.) But oddly the other network issue is most easily diagnosed by turning your network off before starting MATLAB and seeing if it starts quickly. I do not recall what the cause of that second kind of problem was, but I seem to recall that adding an entry for
to your hosts file can help; see http://www.mathworks.com/matlabcentral/newsreader/view_thread/88539 for a mention of where the hosts file lives in MS Windows
  2 件のコメント
Richard 2013 年 12 月 31 日
I will try deleting matlab.prf.
I'm fairly certain this has nothing to do with the network. I'm at work and I've never had a network issue before. I use a standalone license. Before this crash I never had this issue. I have no control over the firewall settings. This busy period happens anytime a variable is created, not just upon startup. That is another symptom that makes me sure it's not network related.
Richard 2013 年 12 月 31 日
The matlab.prf folder is located in the AppData/Roaming/MathWorks/MATLAB/R2012b folder I mentioned I already tried renaming so that MATLAB would create a new fresh folder. This had no effect on the issue I'm describing. The MATLAB preferences are not the problem. Thanks though.


Yaroslav 2017 年 8 月 20 日
I have had the same problem in my R2017a (!) version. I have been inspecting the memory usage and running time of some function, which creates a large array based on an input size parameter. Alas, for a very large size – instead of throwing out-of-memory error – my computer stuck, so I had to forcefully abort and exit Matlab. Moreover, I had to restart the computer, as everything became too slow.
When I returned to Matlab, I have noticed a strange phenomenon: to my horror, everything became 3 times slower than before. Nothing helped:
  • Restarting the computer;
  • Restarting Matlab;
  • Rehashing toolboxes;
  • Removing prefdir;
  • Running disk defragmentation;
  • Running cleanup programs;
  • Even reinstalling Matlab (!) did not help.
Before I continue, I need to emphasize an important point. I have noticed this hindrance in Matlab's speed only because I was probing the run-time to begin with. Impedance of a factor of 3 is not substantial enough to notice in naked eye. Yet, it is a very significant change rendering most of the simulations useless. It could have been weeks before I had noticed something was wrong, and by then it would have been too late, as there would be nothing to compare to. @Sean de Wolski, I believe it is a crucial bug in Matlab that must be addressed.
Finally, what has worked is the following.
  1. Draining the battery of my laptop (Dell Vostro).
  2. Running Dell System Diagnostic Tool at the boot-level. I ran it twice, just in case, with all the options on (with emphasis on memory and cores).
  3. Rebooting the computer.
Matlab is now back to its fast self. Yet, I have no idea why it has succeeded. This behavior should not exist in a ubiquitous program such as Matlab.

Richard 2013 年 12 月 31 日
Could my Java files have been corrupted somehow? If I wanted to replace the java files related to MATLAB (it uses it's own JRE or JDK right, not the one installed under windows programs?) how would I do that? Is there a way I can run a fix tool on it?

Sean de Wolski
Sean de Wolski 2013 年 12 月 31 日
I would recommend first just upping your Java Heap Space. This is the first thing to do for desktop sluggishness.
Go to:
Home Tab - Preferences - MATLAB - General - Java Heap Memory.
Bump this up, apply and restart MATLAB.
Also, make sure you do not have any network directories on your path and that you are not trying to navigate to one in startup.m
  3 件のコメント
Sean de Wolski
Sean de Wolski 2013 年 12 月 31 日
How about your path? Any network directories?
Richard 2013 年 12 月 31 日
No, all local.


Richard 2013 年 12 月 31 日
Even the help function is slow. If I try and do 'help plot' it takes a good 10 seconds for the action to occur. I really could use some help with this MATLAB admins.
  2 件のコメント
Richard 2013 年 12 月 31 日
編集済み: Richard 2013 年 12 月 31 日
Maybe I'm not being clear. There is no program running. This is a MATLAB issue, not a script or function issue.
For example, if you type in your command window the following '2 + 2', you will quickly get the output '4'. If I do that in my command window, I have to wait 10 seconds for the answer.
Example 2: If you type 'help plot' in your command window, you will quickly get the details of how the plot function works and what parameters it can take as input. If I type that in my command window, I have to wait 15 seconds for the output.
Example 3: If I try and run a script, I have to wait 10-20 seconds for the script to begin running. It does not matter how complicated the script is. The script could be as simple as 'y = 2; x = 3; z = x + y' and I will have to wait the minimum 10-20 seconds for it to complete.



Help Center および File ExchangeStartup and Shutdown についてさらに検索


Community Treasure Hunt

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

Start Hunting!

Translated by