🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #173

Re: TADOQuery Memory Leak

#173
From: Arnie
Date: Thu, 03 May 2007 13:47
51 lines
3356 bytes
"Clayton Arends" <nospam_claytonarends@hotmail.com> wrote in message 
news:463779b7$1@newsgroups.borland.com...
> Running on my computer there appears to be a leak.
>
> If the leak is in the VCL then anybody should be able to duplicate the 
> result.
>
> If the leak is in my code then somebody might be able to find it.  Though, 
> I seriously doubt my code is at fault unless there is some initialization 
> routine that needs to be called.
>
> If the leak is somewhere in the ADO drivers then it will depend on the 
> driver versions whether the leak exists or not.
>
> When I find some more time I think I will try this test again without 
> threads to see what happens.  I'm slapping my head right now for not 
> trying that before posting my previous results.
>
> - Clayton

BCB5, ADOExpress

I don't think it's the threads.  We have a service that runs 24/7.  The work 
is done in a thread other than the main service thread.  This thread is 
created when the service starts and only terminates when the service is 
stopped.

The thread sleeps and wakes up every one minute.  It has a list of one or 
more database connections.  When the thread wakes up it creates the needed 
DB objects, opens a connection to a DB and looks for work to do (one or more 
queries).  Then, it closes the connection and destroys all DB objects.  If 
there are more DB connections defined, it repeats the process within the 
same wake cycle.

There are memory leaks and the amount leaked depends on the DB in use.  We 
support Oracle, SQL Server and DB2.  We use ADO over ODBC for DB2.  The 
others use their own OLEDB drivers.

I can see that some of the leaks are due to losing unnamed semaphore handles 
when looking at the service with Process Explorer.  I'm guessing it's either 
ADO or OLEDB that's losing them but can't tell for sure.

I have reproduced the problem in a simple console app.  Loop in main(), 
create the TADOConnection, open, close and delete it.  Sleep for 20 seconds, 
rinse and repeat.

The bottom line is that our customers have to restart the service every day 
or two, a real pain.  So, I'd be interested to know if you find out anything 
further.

- Arnie 
Technical Details
Message-ID: <4639e7d7$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <462d7a19$1@newsgroups.borland.com> <462f9b39$1@newsgroups.borland.com> <462ffa42$1@newsgroups.borland.com> <463018d2$1@newsgroups.borland.com> <4636005c$1@newsgroups.borland.com> <4636da37@newsgroups.borland.com> <463779b7$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,f6b9f007fd37682e
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Arnie" <NoOne@home.now>
Newsgroups: borland.public.cppbuilder.database.ado
References: <462d7a19$1@newsgroups.borland.com> <462f9b39$1@newsgroups.borland.com> <462ffa42$1@newsgroups.borland.com> <463018d2$1@newsgroups.borland.com> <4636005c$1@newsgroups.borland.com> <4636da37@newsgroups.borland.com> <463779b7$1@newsgroups.borland.com>
Subject: Re: TADOQuery Memory Leak
Date: Thu, 3 May 2007 09:47:06 -0400
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 198.172.234.244
Message-ID: <4639e7d7$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1178200023 198.172.234.244 (3 May 2007 06:47:03 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail