Question

I have made a vector of objects that are Domino ViewEntries (they could be Documents or any Domino object for that matter). This is not a ViewEntryCollection nor a DocumentCollection. The list object is a Vector (it could even be an ArrayList). I am aware of this technote about recycling specific objects, but dealing with objects that are in a list is not clear

Do I need to recycle all elements within the Vector individually ? Or can I simply remove them ? If I want to recycle a vector of elements, how would I do this ? is it possible with vectors, or should this be done with a different type of list construct ?

This example leads me to believe that it will not actually recycle them... Discuss.

Vector entries = new Vector();
..... add each ViewEntry to the collection....
for (int i=0;i<entries.size();i++) {
     ((ViewEntry) entries.elementAt(i)).recycle();
}
Was it helpful?

Solution

The recycle() method will remove the backend object for the selected Java Object. Note, that it also removes the backend object for any other Java Object that may be referencing that exact same JNI reference at the same time.

It will also recycle any objects that were created via the class. For example, if you recycle a NotesCollection it should recycle all documents referenced via the NotesCollection. Or more obviously, recycling Session object will recycle everything.

The reason for recycling in a loop is for memory purposes. Be careful if you are storing documents in a vector, as you are holding each complete physical document in memory. It is better to store UNID's and pull in the document as you need it. Or if referencing a view, pull the ViewEntry and not the document. As it will use considerably less memory.

Bobs Balaban's blog articles on this details it quite well.

http://www.bobzblog.com/tuxedoguy.nsf/dx/geek-o-terica-5-taking-out-the-garbage-java

http://www.bobzblog.com/tuxedoguy.nsf/dx/geek-o-terica-6-now-it-gets-complicated-java-garbage-collection-notes-and-threads

http://www.bobzblog.com/tuxedoguy.nsf/dx/geek-o-terica-7-garbage-threads-and-the-corba-classes-in-notes

OTHER TIPS

A Domino object in a container is still a Domino object, so you must invoke recycle on each element to reclaim its memory.

The code you've included accomplishes this task, and there is no way to accomplish this with fewer recycle() calls.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top