Search code examples
javaxpageslotus-domino

recycle domino objects after they are lost


After reading many blogs and posts I already knew, that I must recycle domino objects, before my class and methods ends, to not overloading my heap. But the devil is in the detail, I forgot many times to recycle some objects, so that they are current still alive on the heap.

So my question is, is it possible to collect and recycle them from the heap, without rebooting the server?


Solution

  • A few points:

    1. Recycling Domino objects is nothing to do with overloading the heap. Recycling is because of handles mapping between Java to the underlying C++ Domino object. The Java variables get recycled by normal garbage collection, so the Java heap is unaffected, regardless of whether you recycle or not. What's left are handles to C++ objects and there is a pool of only so many. That's why the error you get is not one about Java memory, but something like "PANIC: LookupHandle: handle out of range".
    2. Multiple Java variables pointing to the same underlying object re-use the same handle. That's why you can get a problem if you recycle a (handle to a) Domino object but are still using that Domino object elsewhere.
    3. At the end of each XPages request (page load, partial refresh etc.) Session, SessionAsSigner etc are recycled. The recycling process recycles all descendants as well. So unless any XPages are stuck in an infinite loop, you cannot still have any objects still alive anywhere.
    4. As mentioned, recycling an object recycles all descendants. But objects like DateTimes and Names are children of the Session, not e.g. ViewEntry. There are various posts about the issues iunvolved and how to resolve.

    That's why there's no reason for concern about recycling except in loops, where it's important to not only recycle the object being iterated, but also any DateTimes or Names created within that loop.