異常一:
異常二:
異常三:
2007-10-25 09:45:47 HTTP JVM: -->java.lang.OutOfMemoryError: JVMCI015:OutOfMemoryError, cannot create anymore threads due to memory or resource constraints
錯誤分析:根據上面提示信息,可以初步斷定一是服務器內存或虛擬內存不足,二是domino自帶的java虛擬機
出了問題。在網上查閱資料,發現主要原因是domino自帶的java虛擬機不會自動釋放資源,導致虛擬機內存耗
盡,在調用java代理時出現溢出。
官方說明:
Each document opened in an agent allocates a private handle. When the document is closed by
the agent, the handle is freed. Loops can be tricky. If the document isn''t closed after processing, a handle will be allocated for every document processed in the loop.
This isn''t a concern in small databases with few documents processed, but in larger databases,
it can become an issue.
之後在designer幫助中,找到:
Java has no knowlege of the heavyweight back-end Domino Objects, only the lightweight Java
objects representing them. Garbage collection has no effect on Domino Objects unless you first
explicitly recycle them.
解決方案:
用LS代理代替所有java代理,這是維持系統穩定的最好方案,在萬不得已要用java代理時可以採取下列
方案補救,但不排除發生異常的可能。
1.及時地對所用到Notes Object(session,agentContext,db,view,document. 等等)進行Recycle()
處理。在代理調用完成時再進行System.gc();System.finalize()。
可以參考IBM網站上的這篇文章:
http://www-1.ibm.com/support/docview.wss?uid=swg21097861;
2.在循環中要注意及時的釋放資源:
while (Doc != null)
{
middleDoc = docView.getNextDocument(Doc);
cal = session.evaluate(config.arc_delete_fomular, Doc);
if (cal.get(0).toString().equals("1.0"))
{
correspond += 1;
}
Doc.recycle();
Doc = null;
Doc = middleDoc;
if (correspond >= config.maxArchive) break;
}
3.在服務器的 notes.ini 文件中,可以增加一個參數:JavaMaxHeapSize=<字節數>
這個參數的具體數值應該根據服務器的硬件環境和應用程序的實際需要來調整,默認的值應該是64M,可以根據
情況適當往大調一下。例如,“JavaMaxHeapSize=268435456” 將此值設爲256MB。
注意:domino只能用4GB的內存,增加或修改此參數後,應重新啓動Domino服務器。
4.對於jar包的調用,最好放在notes.ini文件中,而不是在編寫Java Agent的過程中處理,我們可以將
所調用到的jar文件叢中刪除,在notes.ini文件中增加JavaUserClasses=pathjarFile,具體可以參考IBM網站
上的這篇文章:
http://www-1.ibm.com/support/docview.wss?uid=swg27002721;
5.監控JVM內存使用情況。
通過 Runtime.getRuntime().totalMemory() ,Runtime.getRuntime().freeMemory()可以查看JVM內存
使用情況;在notes.ini文件中增加了JavaVerboseGC = 1的參數,每次在執行該代理的時候觀察內存泄漏的情況。
6.升級domino。理論上IBM會對產品的BUG進行修正,但遺憾的是目前無相關補丁資料及穩定版本信息。
參考資料:
http://blog.csdn.net/wangdeq/archive/2007/10/10/1818246.aspx
http://blog.csdn.net/xaser/archive/2005/11/15/529684.aspx
http://www.hur.cn/program/bbs/Lotus/200601/662594.html
http://topic.csdn.net/t/20040706/15/3150188.html
http://blog.chinaunix.net/u/11279/showart_60477.html
附:下面是一段利用ODBC連接數據庫的程序,自己看看ODBCResultSet類的用法,你就可以讀取、寫入、修改、
刪除數據等等。
Uselsx "*LSXODBC"
Dim con As ODBCConnection
Dim qry As ODBCQuery
Set con = New ODBCConnection
con.SilentMode = False
Print "正在連接關係數據庫..."
If con.ConnectTo("ODBCSource","sa","123") = False Then //ODBC數據源名、用戶名、口令
Print "連接數據庫失敗!"
Exit Sub
End If
Print "關係數據庫連接成功!"
Dim result As ODBCResultSet
Set qry = New ODBCQuery
Set qry.Connection = con
Set result = New ODBCResultSet
Set result.Query = qry
StrSQL = "SELECT * FROM drug"
qry.SQL = StrSQL
If result.Execute = False Then
Print "無法從數據表提取數據!"
Exit Sub
End If
con.Disconnect