Compilefile.this.compileThread = new Thread() {
@Override
public void run() {
try {
synchronized (this) {
Application.getDBHandler().setAutoCommit(false);
MIBParserUtils.getDefaultMibsMap();
compileSelectedFiles();
Application.getDBHandler().CommitTrans();
Application.getDBHandler().setAutoCommit(true);
}
}
catch(OutOfMemoryError exp) {
JOptionPane.showMessageDialog(null, "Compilation Stopped.. Insufficient Memory!!!");
CompileMib.this.compileThread.interrupt();
System.gc();
dispose();
NmsLogger.writeDebugLog(exp);
}
finally {
}
}
我試圖在一個線程中編譯一些文件。 UI選擇超過200個文件進行編譯。在編譯過程中,由於Eclipse中的內存足夠,發生了一個OutOfMemoryError
。我想停止線程並顯示一個消息框,並在我的應用程序中放置編譯窗口。我寫了下面的代碼,但它不工作。我可以捕捉異常並處理它,或者有更好的解決方案嗎?編譯文件時出現內存不足異常
一旦達到OOM狀態,有一個在應用程序的狀態沒有保證。所有投注都關閉。 –
你不能在eclipse.ini中爲eclipse jvm設置更多內存嗎? – kamuflage661
我可以處理catch塊中的異常嗎? – Nikhil