developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum

developerWorks




C# Lotus Notes Problem AllocHandle: OUT OF PRIVATE HANDLES!
Richy T 04/07/2014 05:51 AM
Applications Development All Releases Windows 2003


Hi,

I have an issue where I am getting the below error when interrogating a Notes database through my c# application.

AllocHandle: OUT OF PRIVATE HANDLES! -- pid 00000F38 Handles used so far 6339, Maximum Handles - 16440, error - 0x107

Maximum number of memory segments that Notes can support has been exceeded

I understand the error is due to the Domino private handles limit being reached which I believe is 6,339 although I've read that this has been increased to over 10,000 in more recent versions. I can't do anything about the Lotus Notes infrastructure in my company so I am trying to work around this issue.

The Notes database I need to search has 10,000 dcouments but the view can't be searched on the using the field I wan't to find. I've devised a way where I can work out the required document number I need but in the case that the value I'm looking for doesn't exist I would have to check the value of a notes item in each of the 10,000 documents. In this situation I get the above error when I hit around the 6,000 checks mark.

The code I'm using is similar to the below,

NotesSession session = new NotesSession();
session.Initialize(password);
NotesDatabase NotesDb = session.GetDatabase("NotesServer", "aNotesDB.nsf", false); //Open Notes Database
NotesView pwdView = NotesDb.GetView("(aNotesView)");

for (int i = startingDocNo; i <= startingDocNo + 1111; i++)
{

NotesDocument ndoc = pwdView.GetNthDocument(i);
NotesItem noRef = ndoc.GetFirstItem("aNotesItem");
if (aReference ==noRef.Text)
{
NotesItem theValue = ndoc.GetFirstItem("valueINeed");
valToReturn = theValue.Text;
theValue = null;
break;
}

ndoc = null;

}

pwdView = null;
NotesDb = null;
session = null;

I have tried executing this code in chunks of 1,000 documents but I still get the error. I thought that as I was initializing a new NotesSession object after nullifying the previous one this would reset the handle count. I also tried spawning a new thread to process each 1,000 documents thinking if it was a new thread it could get round the limit but still no luck.

Has anyone got any ideas how to work around this problem, I'm pretty stumped!

Thanks

Richard

Go back