Personal tools

Apr 12, 2012

"Error cleaning up agent threads" - a never ending story

A real case that has been solved

There are thousands of posts on Lotus Domino forum about this problem: "Error cleaning up agent threads".

I ran into a similar problem using a Java agent. I state that this agent has been inherited from another developer ;-) so it was not easy for me to initially understand what the problem could be.

In any case, every time the agent ended, I had the above error to the log.

In truth, none of the posts that I've seen has been helpful, until, by inspecting the code carefully and isolating the parts of it, I found the solution.

One line of code was:

Utils u = new Utils (..... some parameter ....);


where class was imported into the project.
Investigating the Script Libraries containing the class I discovered that it was defined as follows:
public class Utils extends AgentBase {


In practice, the class is defined to extend agentBase, so it's like it was an agent itself. The result is that each time it's loaded, a thread is istantiated.

When finished, the agent's thread was terminated, but the child's thread lost the reference to his father, causing the error.

This problem is naturally solved by changing the definition of the class:

public class Utils {


It may seem a trivial issue, but I guarantee that it is really sneaky, especially if you are working on other people's code.

As you can check on support forums, every developer has a different solution for this problem. In the end, my suggestion are:

- Never extend AgentBase in external class

- use recycle() methods to clean up memory object, expecially in loop code

Any other input on this issue is welcome.

Stay tuned!

Filed under: , , ,
comments powered by Disqus