Article View: borland.public.cppbuilder.nativeapi
Article #9247Re: Thread and memory
From: Sara T.
Date: Tue, 20 Jul 2004 09:10
Date: Tue, 20 Jul 2004 09:10
66 lines
2599 bytes
2599 bytes
Inside my thread, I thought I have clean up all memory already. BTW, I have
used Indy Component and write something into database as example code
following:
void __fastcall CMyThread::Execute(void)
{
// Thread process
//
if (Terminated) return;
try {
try {
AnsiString strHTML = http->Get(strURL);
try {
Synchronize(UpdateDatabase);
} // Processes
catch (...) {
}
::Sleep(200);
}
}
FreeOnTerminate = true;
Terminate();
}
void __fastcall CMyThread::UpdateDatabase(void)
{
int iResult = ERR_OK;
TADOQuery *ADOQuery = new TADOQuery(NULL);
try {
// Assign needed properties to ADO
//
ADOQuery->ParamCheck = false;
ADOQuery->Prepared = true;
ADOQuery->ConnectionString = ""
AnsiString strSQLString; = <Some SQL Statement>
strSQLString = ADOQuery->SQL->Clear();
ADOQuery->SQL->Add(strSQLString);
int iSuccess=ADOQuery->ExecSQL();
}
catch (...) {
}
delete ADOQuery;
}
}
Sara T.
"JD" <nospam@nospam.com> wrote in message
news:40fcc3d3$1@newsgroups.borland.com...
>
> "Sara T." <sarana@infoquest.co.th> wrote:
> > [...] In fact the line number 1: has been called a lot of
> > times and I thought that it should be OK if it is a thread
> > with using FreeOnTerminate.
>
> As Gambit pointed out, there's nothing wrong with what little
> code you posted. If you're sure that it's the thread that's
> eating memory, then you need to post a more complete sample.
>
> ~ JD
>
Technical Details
Message-ID:
<40fce10f@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40fb3d08@newsgroups.borland.com> <40fbf87b$1@newsgroups.borland.com> <40fbfd74$1@newsgroups.borland.com> <40fc1022$1@newsgroups.borland.com> <40fcab00@newsgroups.borland.com> <40fcc3d3$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d35c53850c011fac X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Sara T." <sarana@infoquest.co.th> Newsgroups: borland.public.cppbuilder.nativeapi References: <40fb3d08@newsgroups.borland.com> <40fbf87b$1@newsgroups.borland.com> <40fbfd74$1@newsgroups.borland.com> <40fc1022$1@newsgroups.borland.com> <40fcab00@newsgroups.borland.com> <40fcc3d3$1@newsgroups.borland.com> Subject: Re: Thread and memory Date: Tue, 20 Jul 2004 16:10:37 +0700 Lines: 68 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 169.210.34.33 Message-ID: <40fce10f@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1090314511 169.210.34.33 (20 Jul 2004 02:08:31 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail