Link to home
Start Free TrialLog in
Avatar of Santino_k
Santino_k

asked on

NSD Running (probably Memory Problem)

Hi,
I have developed an Add-in for Lotus Notes 6.0
When i do an operation on notes, NSD runs and log is created.

I tried analyzing the log myself and also traced my whole code.I found that it fails on call to NSFItemIsPresent(...) API.

The problem is i dont get NSD error when i have 512 MB ram but it occurs everytime and at same place when i have 256 MB Ram on my machine...(thats my observation)...

Can any one help me with this problem as soon as possible.

I m wondering if its the problem with my Add-in or Notes doesnot find enough memory.(Actually i have checked for memory leaks but found none in my source code)

Also Can any one tell me , when does NSD run? (I have checked with my JIT debugger and its Not NSD so i assume that Notes itself starts NSD)
SOLUTION
Avatar of HemanthaKumar
HemanthaKumar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Santino_k
Santino_k

ASKER

Hi Hemanth,

I have checked with my source code and didnt find any leak there... still i'll have a look once...

Can you tell me that if there is insufficient memory for notes to run... does NSD run?
Sometimes this happens even with LS.. I don't blame your code.

While my LS Code works in one machine, it would fail on another machine which might have same configuration.. but incompatible drivers..

You have to check what are all the other process that is running during this crash.. try to minimize other apps and see how your code functions. There can be several reasons that could cause this problem..

Have u coded this in C++ or Java ??
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi HemanthaKumar,

I have coded in C++. I'll take a look at it after minimizing other apps.


Hi qwaletee,

Even i was thinking about what u said  -- " Notes could run out of internal pool"

I'll check out ... hope it gets fixed soon
Just wondering... did you ever get to the bottom of this?
Hi qwaletee,
No I am still struggling with it.
I had left it pending but from last few days I have again started working on it but I am not able to find the exact cause.
It fails at same point in my code when I call NSFItemIsPresent(...) API (I checked it in Notes header file and found its a macro. I used the underlying function NSFItemInfo(...) that it aliases to but still the problem persists).

Following is the brief Stack trace --
@[ 1] 0x6018eb23 nNOTES._Panic@4+483 (609d0016,213,0,12ef9c)
@[ 2] 0x60002576 nNOTES._LockHandle@12+294 (213,12ef98,12efa4,0)
@[ 3] 0x60009bd6 nNOTES._OSMemGetFaultHandle@4+22 (60bad0c6,7c6c10,0,213)
@[ 4] 0x60009c81 nNOTES._OSLockPool@8+17 (12efdc,213,7c6c10,0)
@[ 5] 0x6001062e nNOTES._NSFItemInfo@28+30 (213,7c6c10,12,0)
.....

I have a NSF hook installed wherein Notes calls a my Update function passing the NOTEHANDLE. I pass this note handle to NSFItemIsPresent(...) API.

Can you please help me in some direction what can be the problem?

Thanks.

Regards,
Santino
Do you check the validity of the notehandle before you use it?
Hi qwaletee,
I was suspecting that I may be having an invalid notehandle.
qwaletee I have an event handler DLL that I have registered with Notes. Now when I get an event of a particular note being updated in this Event Hadnling DLL, I delegate this event to another Process using SendMessage API (I am using VC++).
To counter check I used the NSFItemIsPresent API in My Event Handling DLL and It worked but when for same NoteId I used NSFItemIsPresent API in my Request Processing Process it gave the above discussed NSD error.

Can you tell me how I can check validity of this Note Handle in my Request Processing Process???

Awaiting your reply.

Regards,
Santino

(If you want I can ask this as a seperate question but then I would want you to be the person answering it :-D )
Also I have a check in Request Processing Process for NoteHandle not being NULL. If it is NULL I display an error message. But I verified that the handle is not NULL when I process this handle in Request Processing Process.

In above Message I said
"To counter check I used the NSFItemIsPresent API in My Event Handling DLL and It worked but when for same NoteId I used NSFItemIsPresent API in my Request Processing Process it gave the above discussed NSD error."

Its actually NOTEHANDLE that I pass to NSFItemIsPresent and not NoteId.
Each process must initialize the Notes API separately, which could be your problem.  Also, I just don't know if a handle created under one API initialization would be valid in a second... might be OK, might not.

Why don't you dispatch the delegation to a separate thread within the same process, instead of into a separate thread?  Unless delegation is so that a separately-launched UI can handle it, there should be no need to do this.

If all else fails, you can simulate this, as long as you are using post-event notification, not pre-event notification.  You can extract the server/file/noteID from the notehandle in the event handler, and just pass this identifying data to the other process.  The only downsides:
1) Wateful to retrieve the note again if you already had it
2) Be careful not to cause an endless loop by modiying the note, or your event will get fired again.
3) As I said, only good for post-even handling, where the process is in the same level as the event handler was vis-a-vis preemptive access to the data.  In before event handling, the event handler has access to a note that has not yet been written to disk, and can lock access to the note and update it before it gets written.  What the delagted task would have is an already-written note that is available to other process already, and any further write to the note would count as a second update
Hi qwaletee,
Thank you very much for this detailed information.
I'll try what you have said and will let you know how things work out :-)

Thanks again.

Regards,
Santino
Hi qwaletee,
what I have implemented is NSF_HOOK and not Extension manager.
So dont know how to run that after note updation.
The even gets trapped in MyNoteUpdate(...) function whose pointer I set in DBHOOKVEC passed by Lotus Notes to my NSF_HOOK Dll's main entry point.
I tried using the server/file/noteID in my delegated task processor but got Notes hung after sometime. I logged the activity and found that I entered an endless loop.

Do you know how I can implement the NSF_HOOK so as to recieve notification after note gets updated or should I queue all requests in my delegated task process and then process them?

You are getting a loop because when your second process saves the note, it is triggering an additional hook call.  So, what you may want to do is have the second process set a dummy item on the document before it saves it.  The main hook can check if the dummy item is present.  if it is NOT present, it dispatches the event to the second process.  If the dummy item IS present, it removes the item (we don't want it to actually get saved!), lets the save proceed, and does NOT dispath an event.

If you queued the updates, you would run into teh same problem (and could use the same solution).

Note: as outlined above, this isn't very sophisticated, which means a system design could bypass your processing by adding the same dummy note item.
Hi qwaletee,
I tried things we discussed. But I think the whole problem is due to the existing design of my system.(I read somewhere that you should not use the notehandle in different threads also and here I am using it in seperate process.)
I cannot reopen the DB in which note exists because that triggers the NoteOpen Operation again so I cannot set some value in the document. But now I think I'll try with some other way but on similar line what you have told. Instead of setting value in some document I'll try setting some systems global value. With this I'll atleast check if things work then probably I can proceed without major changes to my design.
Will let you know about result once done.
BTW where are you from qwaletee and do you exclusively work on Lotus Notes?(answer only if I am  not getting personal)

Have a nice day
Regards,
Santino
I'm in NYC, and most of what I do is Lotus Notes.
Hi qwaletee,

I am in India. Have just appeared for my final year of Masters in Computer Science. Am expecting my results by end of the month :-)

I tried synchronization of Note open and update. but things are not working. I am not able to open the database (ie:- Users mail file). Am working on it. will update you on what happens.

ciao,
Bye
have a nice day
OK, thanks.  Sounds like a tricky thing to do, if you succeed, please post code (for both dispatch and consume).