(1) 系統+軟件版本
CentOS 6.5 (Final), 64 位,內核initramfs-2.6.32-431.5.1.el6.x86_64,
MATLAB Version: 8.1.0.604 (R2013a)
Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
(2) 問題描述
通常在這個環境下,小文件的代碼都可以調試通過.
最近,把所有函數集合到一個M文件(332.4 kb),只是簡單地設置了幾個斷點, 運行到斷點位置再停止運行, cpu和內存占用都還算正常.
但接下來對m文件的編輯就開始變得非常慢, 甚至是只添加幾個單詞就會卡住, 一直沒有響應, 內存占用不變, 而1/4核CPU的占用高達100%, 只能從系統監視器里殺死進程.
我猜想, Matlab對M文件大小的支持,是不是非常有限? 子函數版本太多也是罪過,想着集成起來可以方便調用和標注,沒想到弄巧成拙了...
(3) 解決辦法
找到兩個解決辦法.
一是使用 '-singleCompThread' 參數啟動matlab. 親測可用. 調試編輯都和原來基本一樣, 不再卡頓了. 這要感謝水木網友 @RSVP 的耐心解答.
[usr@usr ~]$ matlab -help
Usage: matlab [-h|-help] | [-n | -e]
[-arch | v=variant | v=arch/variant]
[-c licensefile] [-display Xdisplay | -nodisplay]
[-nosplash] [-mwvisual visualid] [-debug] [-softwareopengl]
[-desktop | -nodesktop | -nojvm]
[-r MATLAB_command] [-logfile log]
[-Ddebugger [options]]-h|-help -Display arguments.-n -Display final environment variables,
arguments, and other diagnostic
information. MATLAB is not run.-e -Display ALL the environment variables and
their values to standard output. MATLAB
is not run. If the exit status is not0 on return thenthe variables and values
may not be correct.-arch -Start MATLAB assuming architecture arch.
v=variant -Start the version of MATLAB foundin bin/glnxa64/variant instead of bin/glnxa64.
v=arch/variant -Start the version of MATLAB foundin bin/arch/variant instead of bin/glnxa64.-c licensefile - Set location of the license filethat MATLAB
should use. It can have the form port@host or
be a colon separated list of license files.
The LM_LICENSE_FILE and MLM_LICENSE_FILE
environment variables will be ignored.-display Xdisplay -Send X commands to X server display, Xdisplay.-nodisplay -Do not display any X commands. The MATLAB
desktop will not be started. However, unless-nojvm is also provided the Java virtual machine
will be started.-nosplash -Do not display the splash screen during startup.-mwvisual visualid - The default X visual to use forfigure windows.-debug - Provide debugging information especially forX
based problems.-desktop -Allow the MATLAB desktop to be started by a
process without a controlling terminal. This is
usually a required command line argument when
attempting to start MATLAB from a window manager
menu or desktop icon.-nodesktop -Do not start the MATLAB desktop. Use the current
terminalforcommands. The Java virtual machine
will be started.-singleCompThread -Limit MATLAB to a single computational thread. By default, MATLAB makes use of the multithreading
capabilities of the computer onwhichit is running.-nojvm -Shut off all Java support by not starting the
Java virtual machine. In particular the MATLAB
desktop will not be started.-jdb [port] - Enable remote Java debugging on port (default 4444)-r MATLAB_command -Start MATLAB and execute the MATLAB_command.-logfile log -Make a copy of any output to the command windowin filelog. This includes all crash reports.-Ddebugger [options] -Start debugger to debug MATLAB.-nouserjavapath - Ignore custom javaclasspath.txt and javalibrarypath.txt files.
二是使用外部編輯器 Emacs 來編輯和調試. 調試采用 matlab-shell mode, 稍微復雜一些, 傳統的快捷鍵都不怎么能用, 只能用命令設置斷點和運行, 涉及到的命令有: dbstop & dbstatus & dbcont & dbquit 等, 可參閱這篇博客. 在調試過程中編輯腳本也沒問題, matlab 占用也小. 有關 Emacs 多窗口之間切換的快捷鍵可以參考 學習Emacs系列教程(十):多窗口.
全文完.