Search found 4 matches

by bjans
Wed 17 Sep 2014 08:32
Forum: SQL Server Data Access Components
Topic: Connection pooling
Replies: 8
Views: 25777

Re: Connection pooling

Do you have any results already?
by bjans
Fri 29 Aug 2014 06:46
Forum: SQL Server Data Access Components
Topic: Connection pooling
Replies: 8
Views: 25777

Re: Connection pooling

Hello...? Anybody there?
by bjans
Wed 27 Aug 2014 08:47
Forum: SQL Server Data Access Components
Topic: Connection pooling
Replies: 8
Views: 25777

Re: Connection pooling

I emailed you a sample application. Could you reproduce the problem?
by bjans
Fri 22 Aug 2014 09:45
Forum: SQL Server Data Access Components
Topic: Connection pooling
Replies: 8
Views: 25777

Connection pooling

I'm trying to set up connection pooling for my application but I'm not sure how to do it the right way.

My app is a web server that handles requests in threads. Eacht thread has its own connection that shoold be pooled. The DB coe looks like this:

Code: Select all

begin
  FDBCon := TMSConnection.Create(nil);
  try
    FDBCon.Server := FServer;
    FDBCon.Database := FDatabase;
    FDBCon.Username := FUser;
    FDBCon.Password := FPassword;
    FDBCon.Pooling := True;
    FDBCon.PoolingOptions.ConnectionLifetime := 60000;

    // create query and do stuff qith query / FDBCon

  finally
    FDBCon.Free;
  end;
end;
This works, but when the application terminates I get an exception with this call stack:

Code: Select all

OLEDBAccess.TOLEDBConnection.Disconnect
CRConnectionPool.TCRLocalConnectionPool.InternalFreeConnection($40FA640,False)
CRConnectionPool.TCRLocalConnectionPool.Clear
CRConnectionPool.TCRLocalConnectionPool.Destroy
System.TObject.Free
MemUtils.TDAObjectList.Notify($3D02DE0,lnDeleted)
System.Classes.TList.SetCount(0)
System.Classes.TList.Clear
CRConnectionPool.TCRConnectionPoolManager.InternalClear
CRConnectionPool.TCRConnectionPoolManager.Destroy
System.TObject.Free
MSConnectionPool.Finalization
I think the DBConnections that I freed earlier are still in the pool and destroyed again. If I don't free the FDBCon in the threads I don't get the exception on termination but then I have a memory leak for each TMSConnection.

How should I implement the lifecycle for a TMSConnection in a pooled situation?