logo

New Response

« Return to the blog entry

You are replying to:

    • avatar
    • Shane
    • Posted on Wed 1 Sep 2010 01:31 AM

    I was tasked with fixing an application about 8 years back using the Java API. It was successfully crashing an AS400 every three or four minutes.

    My resolution, when IBM couldn't help, was to create a single global static NotesSession object and use that for all connections / work. It started when the app started and closed when the app closed. It was never released. There was only ever one instance

    I also did that as much as possible for my database object (where the database needed to be opened in a single thread ).

    i explicitly garbage collected (obj.gc) then set to null / nothing (in vb - set obj=nothing ) everything.

    I also got very anal about dimensioning objects in order and closing them in order ie parents open before children, children close before parents.

    This resolved the problems. The biggest resolution was a SINGLE SESSION object. however dont forget to close children before parents incase a reference is held open and the cascade collection of

    killing the parent doesn't clean up the child object and leaves pointers open - yes even in VB / Lotus Script.

    For what it is worth.

    My std sub or function now looks a bit like the following - note the catch all clean up in each sub

    --- CODE START ---8<----

    global gSession as NotesSession

    sub Initialise_StartHere

    on error goto errHandle

    'Start Globals

    set gSession = new NotesSession

    ' Run Main Sub / Function / Controller for App

    call Foo()

    finalExit: ' clean up globals

    on error resume next

    set gSession = nothing

    exit sub

    errhandle:

    ' do what ever here if required.

    ' ie msg box, clean up or what ever

    goto finalExit

    end sub 'Initialise_startHere

    Sub Foo()

    ' this is the main control loop / app handler

    on error goto errHandle

    ' dim and initialise parent obs first

    dim db = as NotesDatabase

    dim view = as notesView

    dim dc as NotesDocumentCollection

    dim doc as Notesdocument

    dim item = as NotesItem

    set db = gSession.openDB .....

    set view = db.GetNotesview("Name")

    set dc = db.Search ....

    set doc = view.GetfirstDocument

    set item = doc.GetFirstitem(.....

    ' do my stuff here

    finalExit: ' this is the catchall Clean up

    on error resume next

    ' kill everything even if it doesnt exist just in case

    'kill child before parents

    set item = nothing

    set doc = nothing

    set dc = nothing

    set view = nothing

    set db = nothing

    exit sub

    errhandle:

    ' do what ever here if required.

    ' ie msg box, clean up or what ever

    goto finalExit

    End Sub 'Foo

    --- CODE END --->8----

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment: