After Allocating a Large Variable and Crashing, MATLAB is Forever Slow
23 次查看(过去 30 天)
显示 更早的评论
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
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
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
2014-1-1
编辑:Yair Altman
2014-1-1
Several possibilities spring to mind:
- Your antivirus is running wild ( link1, link2, link3 )
- You are using a CVS (code-versioning system) that is ill-configured
- 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
- You have clashes with other software that uses the same FLEXnet license manager as Matlab ( link1, link2 )
- You have mapped drives that are disconnected for some reason but Matlab doesn't know this
- You have a very long Matlab path
- You have defined a function somewhere on the Matlab path that has a name which overrides some internal Matlab function
- Your Matlab installation is critically fragmented on disk (=> run a defragmetation utility)
- You are using a toolbox that is ill-configured (e.g., symbolic toolbox)
- You are running Matlab via an X-server or SSH
- You have disabled toolbox caching in the global Matlab preferences
- You have defined numerous workspace variables
- You have numerous files loaded in the Editor
- You have multiple open figure windows
- You are using SELinux without setting the allow_execheap flag (so JIT is disabled)
- You are using a vast number of Windows fonts
- You are using unnecessary web-proxy auto-discovery
- 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
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
localhost 127.0.0.1
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
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.
- Draining the battery of my laptop (Dell Vostro).
- 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).
- 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.
0 个评论
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 个评论
Richard
2013-12-31
2 个评论
Walter Roberson
2013-12-31
Perhaps profiling would help narrow the problem.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!