所有定义的对象需要回收—
重定义之后需要回收注意!
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;
}