OutOfMemoryError: Notes-JavaAgent running on domino server

Hi,

I’m starting an java-agent in notes. This agent searches in the content manager for archived emails.

After 5 searches I get the following error:

12/08/2009 11:21:51 AM Agent error: java.lang.OutOfMemoryError

12/08/2009 11:21:51 AM Agent error: at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:116)

12/08/2009 11:21:51 AM Agent error: at lotus.domino.ClassHashtable.explodeArchive(Unknown Source)

12/08/2009 11:21:51 AM Agent error: at lotus.domino.ClassHashtable.addAttachment(Unknown Source)

12/08/2009 11:21:51 AM Agent error: at lotus.domino.AgentLoader.addAttachment(Unknown Source)

12/08/2009 11:21:51 AM JVM: The addAttachment (Ljava/lang/String;[B)V() method failed.

I don’t know what the problem is.

I start my agent within an notesagent like this:

Dim searchAgent As NotesAgent

Set searchAgent = db.GetAgent(“(SearchAgent)”)

Dim status As Integer

status = searchAgent.RunOnServer(profileDoc.NoteID)

And the search Agent looks like this:

public void NotesMain() {

Database db = null;

AgentContext agentContext = null;

Agent agent = null;

Document profileDoc  = null;

String noteid = null;

    String strDatabase = null;

    String strUsername = null;

    String strPasswd = null;

    String query = null;

try {

	session = getSession();

	agentContext = session.getAgentContext();

	db = agentContext.getCurrentDatabase();

	agent = agentContext.getCurrentAgent();



	noteid = agent.getParameterDocID();

	agent.recycle();

	profileDoc = db.getDocumentByID(noteid);

      	

	query = profileDoc.getItemValueString("searchQuery");

      	if(query == null){

      		return;

      	}



      	dsICM = new DKDatastoreICM();

      	dsICM.connect(strDatabase, strUsername, strPasswd,"");

        	int foundDocs = searchInContentManager(query, profileDoc, db);



        	profileDoc.recycle();

        	db.recycle();

        	session.recycle();

        	

	dsICM.clearCache(DKConstant.DK_CM_CLEAR_CACHE_ALL);

      	

        	dsICM.disconnect();

        	dsICM.destroy();

        	System.out.println("Disconnected from datastore");



} catch(NotesException e) {

	e.printStackTrace();

} catch (DKException e) {

	e.printStackTrace();

} catch (Exception e) {

	e.printStackTrace();

} finally{

	try{

		if(session != null) session.recycle();

		if(db != null) db.recycle();

		if(agentContext != null) agentContext.recycle();

		if(agent != null) agent.recycle();

		if(profileDoc != null) profileDoc.recycle();			

			

	} catch(NotesException e) {

		e.printStackTrace();

	} catch (Exception e) {

		e.printStackTrace();

	}

}

}

My JavaMaxHeapSize in the notes.ini from the Dominoserver has the value 384MB

I clear all Java-Objects, if possible.

What can I do that I don’t get this error again?

Please help me!