🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1492

Re: std::auto_ptr<> Memory Leak?

#1492
From: Dan
Date: Mon, 13 Aug 2007 20:16
54 lines
3013 bytes
> Are you sure that this is the code? EndTime isn't declared at this point.

You are correct, no this isn't the 'exact code'  EndTime should be 
StopTime.  I've ran another test more straightforward test with the 
following code:

void TForm1::TestFunctionButtonClick(TObject *Sender)
{
    std::auto_ptr<TStringList> Times(new TStringList());
    const int Number_Of_Loops = 100;
    for (int i=1; i<Number_Of_Loops; i++)
    {
     const String Time1 = GetTimeMessage();

     std::auto_ptr<TADOQuery> Query(new TADOQuery(this));
     const String Time2 = GetTimeMessage();

     Query->Connection = Database;
     Database->Connected = true;
     const String Time3= GetTimeMessage();

    const String SQL = "Select * from Samples where Sample_ID = 
"+(String)i+" and Sub_Sample_ID = 1";
     Query->SQL->Text = SQL;

     Query->Active = true;
     const String Time4= GetTimeMessage();
 
Times->Add((String)MillisBetween(Time1,Time2)+"\t"+(String)MillisBetween(Time2,Time3)+"\t"+(String)MillisBetween(Time3,Time4));

    }
    ShowReadOnlyInformation("Times",Times->Text);
}


The upside is that I don't see performance drags between creation of the 
auto_ptrs (Time 1 and Tim2e for example).

I do see the 'processes' memory number increase while the loop is going 
on; and I do see that the SQL->Active call (Time 3 to Time 4) is almost 
completely random.  While I don't see a huge trend line upwords as I 
initially thought, I do see that a handful of the 100 SQL->Active calls 
sometimes take over 4 seconds to complete, vs the average is around 
100ms; and the number of calls that take much more than the average time 
increases as I get further in the loop.

And no, on subsequent calls the select statements that are slower are 
not for the same records, or in otherwords one call that took 4 seconds 
on one run may take 100ms on the next and vice versa.  The database is a 
local Access database.

So I think I have a memory issue, looking at the task manager, but I am 
more confused why the turn around times for SQL->Active aren't consistent.
Technical Details
Message-ID: <46c0bc23@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <46c0acfc$1@newsgroups.borland.com> <m24pj3qjz1.fsf@glue.ch>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,a638a12efe982a3a
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Mon, 13 Aug 2007 15:16:36 -0500
From: Dan <Dan@do.not.spam>
User-Agent: Thunderbird 1.5.0.12 (Windows/20070509)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: std::auto_ptr<> Memory Leak?
References: <46c0acfc$1@newsgroups.borland.com> <m24pj3qjz1.fsf@glue.ch>
In-Reply-To: <m24pj3qjz1.fsf@glue.ch>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 216.174.165.174
Message-ID: <46c0bc23@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1187036195 216.174.165.174 (13 Aug 2007 13:16:35 -0700)
Lines: 54
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail