One of the things to be aware of when using Java in Notes is memory consumption. (Almost) All Notes java objects has a method called 'recycle()'. Use it!! Use this for 'garbage collecting' for Notes specific objects, and rather overdo it than not do it...
While LOOPING and selecting in e.g. documents from a view, the previous selected document will be kept in memory EVEN if overwritten/replaced with a new value. Why? I do not have a good explanation, but just accept that this is the way it is...(and save yourselves from memory exhaustion and other troubles...)
A good way of avoiding this is the following method, or variants over the same theme:
...
View view = null;// NotesView in LS
Document doc = null; //NotesDocument in LS
...
//Variables above initialized and 'not null'//
doc = view.getFirstDocument();
while (doc != null)
{
...
// Some action/statements on the main doc...
...
Document tmp = view.getNextDocument(doc);
if (doc != null) doc.recycle();
doc = tmp;
// tmp is not necessary to recycle, but I normally do that anyway just to be sure...
if (tmp != null) tmp.recycle();
}
...
// Finished with operation on view:
if (view != null) view.recycle();
// the 2 lines below is AGENT specific...
if (agentcontext != null) agentcontext.recycle();
if (session != null) session.recycle();
...etc...
This method should keep your agent or other java code running more stabile and with less 'leakage' in memory. One of the most frustrating messages on a Domino console is 'JVM can not execute agent. Out of memory'...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.