domino使用java 代理注意说明与java内存监控

所有定义的对象需要回收—

重定义之后需要回收注意!

sysdoc.recycle();
sysview.recycle();
view.recycle();
doc.recycle();
db.recycle();

session.recycle();
System.gc();

帮助手册里面的样例写法

import lotus.domino.*; 
public class JavaAgent extends AgentBase { 
public void NotesMain() {
try { 
Session session = getSession(); 
AgentContext agentContext = session.getAgentContext(); 
Database db = agentContext.getCurrentDatabase(); 
View v = db.getView("SomeView");
// turn off auto-update so that if we make a change to a document // and resave, it won't affect the sort order in the view 
v.setAutoUpdate(false); 

Document doc = v.getFirstDocument(); 
Document temp = null;   
//sets the temp for garbage collection immediately 

while (doc != null) 
{ 
// do something with the document here... 
// whatever, just don't delete it (yet)! 
temp = v.getNextDocument(doc);   // get the next one 
doc.recycle();  // recycle the one we're done with 
doc = temp; 
} 
// end while 

} catch(Exception e)
{ 
e.printStackTrace(); 
}
}
}

如何进行视图循环

View docView = config.app_db.getView("ALLDOC");
Document middleDoc;
Document curDoc = docView.getFirstDocument();
Vector cal = new Vector();
while (curDoc != null){
    middleDoc = docView.getNextDocument(curDoc);
    cal = session.evaluate(config.arc_delete_fomular, curDoc);
    if (cal.get(0).toString().equals("1.0")){
        correspond += 1;
    }
    curDoc.recycle();
    curDoc = null;
    curDoc = middleDoc;
    if (correspond >= config.maxArchive) break;
}

其他

Domino中使用JAVA代理一定要小心,特别是R5的版本。 


1、及时地对所用到Notes Object(session,agentContext,db,view,document. 等等)进行Recycle()处理。可以参考IBM网站上的这篇文章: 
http://www-1.ibm.com/support/docview.wss?uid=swg21097861; 

2、对于jar包的调用,最好放在notes.ini文件中,而不是在编写Java Agent的过程中处理, 

我们可以将所调用到的jar文件丛中删除,在notes.ini文件中增加JavaUserClasses=pathjarFile,具体可以参考IBM 网站上的这篇文章: 
http://www-1.ibm.com/support/docview.wss?uid=swg27002721; 

3、确认有足够的Java内存堆栈 
缺省的情况下为64M,可以根据实际情况来调整堆栈大小,可以在notes.ini文件通过JavaMaxHeapSize参数进行调整,具体可以参照 Administrator帮助; 
4、监控JVM内存使用情况 
通过Runtime.getRuntime().totalMemory() , Runtime.getRuntime().freeMemory()可以查看JVM内存使用情况; 
5、使用System.gc() 强行进行垃圾回收。 

用户可以在notes.ini文件中增加了JavaVerboseGC = 1的参数,每次在执行该代理的时候观察内存泄漏的情况。 
以前碰到一个很妖怪的情况,可以和大家分享, 
通过在notes.ini中增加参数JavaUserClasses= pathfilename来存放jar包。但是将其放在Notes.ini的最后一行会有内存泄漏,后来将该参数没有放在最后一行,就不会有内存泄漏。

  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值