Subject Re: [IBO] Problem with IB_Session
Author Helen Borrie
At 10:14 AM 30/08/2006, you wrote:
>I have been using IB_Sesion through a multi-threaded application without
>problem for some time. However this morning I have been having major
>problems with a new thread I created.
>When the thread frees it causes multiple AVs (close one, get another).
>I have tracked through the code and reduced it down so it essentially
>creates and frees. The only component being created or freed now is an
>IB_Session. I have discovered the difference between this thread and
>others, this one uses FreeOnTerminate, my other threads are manually
>freed. If I change the thread to be manually freed it no longer AVs.
>Any suggestions as to what I am doing wrong?
>Sample code follows (All code in the execute has been removed) All
>other code in the creator and destructor has been commented out)
>constructor TSendFTP.Create(ibPath, ibServer : String);
> inherited Create(True);
> FreeOnTerminate := True;
> fIb_Session := TIB_Session.Create(Nil);
> fIb_Session.UseCursor := False;
>destructor TSendFTP.Destroy;
> if (fIb_Session <> Nil) then begin
> fIb_Session.Free;
> end;
> inherited Destroy;
>//Calling code
> FTP := TSendFTP.Create(Path, Server);
> FTP.UploadFile(FileName, False); //UploadFile triggers the
>execute method

This is too terse to pinpoint the exact problem but 2 things I notice are:

1. The session is being created with no owner.

2. Destroying the session is the first thing the destructor
does. What about the data access objects (connection, statements)
? The session has to be created before them and destroyed after
them, otherwise they are left referring to a session that doesn't exist.