matlab 解除文件占用,Linux x64 下 Matlab R2013a 300 kb 腳本文件調試的 CPU 占用過高問題的解決辦法...

(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文件大小的支持,是不是非常有限? 子函數版本太多也是罪過,想着集成起來可以方便調用和標注,沒想到弄巧成拙了...

7270e9cc1f041d6e66895229de182f79.png

60275470d0f322a0a1fee25207f92327.png

(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系列教程(十):多窗口.

690ea548cff9efd1173f6ddd6c5e3661.png

全文完.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值