nsftools blog | comments

[1] Duffbert @ 01:42PM | 2004-02-18

Great stuff, Julian... thanks for pointing that one out.


[2] jonvon @ 11:52PM | 2004-02-18

you know i thought they went way out of their way to say *not* to recycle agentContext in the ND6 docs. but i could be on crack again. was hitting the pipe this morning. i really should look it up before opening the old hatch, but that would mean i'd have to open up the 6 client... etc.


[3] Andrew Tetlaw @ 11:59PM | 2004-02-18

Well, the help does say this generally about recycle:

"If you create more than one object to represent the same Domino element, recycling one recycles all. For example:
View v1 = db.getView("All");
View v2 = db.getView("All");
v1.recycle(); // also recycles v2
Results are undefined if you attempt to use a recycled object. No error is guaranteed."

Which I guess, should make you use recycle very carefully. Especially if you are making new session objects everywhere... to which there is this specific comment:

"In Session, call recycle() only after all other threads exit."


[4] Julian Robichaux @ 03:07AM | 2004-02-19

Tom: no, no. Thank you...

jonvon: well, it might be in the Help somewhere. I don't remember reading it, but that doesn't mean anything. I don't always read instructions...

Andrew: yeah, I can see the point in the example about getView, because those are both pointing to the same object. I just never expected AgentContext to be static, especially if I got it from a Session that I created from a NotesFactory. Maybe I should have. I dunno.

I still struggle with the whole recycle() concept anyway I guess. It seems very anti-garbage collector. With any luck, the light bulb will go on in my head someday.

- Julian


[5] Andrew Tetlaw @ 05:06AM | 2004-02-19

I have a feeling the reason why it don't work for you is because all the code is running inside the Notes JVM, which runs inside the C wrapper ... and so on. Only one C pointer for the session hence every time you grab a session you get it, even with NotesFactory because it's all running inside the wrapper.

I reckon if you were running a few servlets, and grabbed sessions using NotesFactory you'd have a different experience.





[6] Julian Robichaux @ 05:27AM | 2004-02-19

I don't know, I though it was strange that calling recycle() on the Session that I created didn't cause any problems, but calling it on AgentContext did. I'd have thought that if there was a problem with one, there would be a problem with both. There's just something there that I can't quite get my brain around...

- Julian


[7] Johan K @ 08:00AM | 2004-02-19

Tip: decompile Notes.jar and look in the AgentLoader, AgentLauncher and NotesThread classes, and you might get a clue. A quick glance in it, and I see that the AgentContext is created only once per session. Look in the getAgentContext() in the Session class.


[8] jonvon @ 07:49PM | 2004-02-19

wow, i had to read this like three times before i finally got the gist of what you were getting at, namely

"despite the fact that I instantiated a completely different Session object to get it from"

now that IS interesting. on a long support call (that went on for weeks and never got resolved cuz i ran out of time by the time "development" finally got involved and i had to do something ugly, long story) about corba sessions and whatnot, the support people told me that objects in one session should not be accessible in another session. i don't know if that is an r5 thing or what, or if it is even true. i never had time to investigate it.

so the theory went, if you had a new session that you had instantiated to say, go get some resources on another server or something, the only thing you could pass back to your original session (coming out of agentbase, etc) would be String objects or some other native java object. in other words, the two sessions were supposed to be completely separate.

maybe the theory only applies if you are creating a remote session.

one of these days i too hope to understand all of this java stuff.

i poked around a bit and couldn't find the help thing i think i may have read. but on thinking about it further, it might have been from a View session (as in The View Conference) put on by Tony Higham. i could be wrong, but i think his recommendation was to not recycle session and not recycle agentcontext, but to recycle everything else. and supposedly in servlets you don't call recycle, everything gets automatically collected. i wonder if that applies to remote sessions too...

i thought this was a good article:

http://www-10.lotus.com/ldd/today.nsf/Lookup/Java_access_pt1

sorry, i think maybe i've blogjacked this thread.




[9] Chad Schelfhout @ 01:27AM | 2005-07-15

Over a year later and your tip is still usefull.

Thanks


[10] Matt @ 10:27AM | 2007-06-07

And almost 2 years after that - this has saved me an afternoon of head-scratching Thanks!


add a comment

name:
e-mail:
www:

HTML markup is not allowed in your comments, although URLs will be automatically converted to links (make sure there is a space before and after the URL).