🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.multi-tier
Article #1233

Re: Memory usage increase using TClientDataSet as a local temporary dataset

#1233
From: Michael A. Feinstein
Date: Mon, 17 Apr 2000 00:00
56 lines
2720 bytes
I also found that following constructions leak memory (string "FIELDNAME" to be
specific) in C++ Builder 4 :

Dataset->FieldByName("FIELDNAME")->AsSomething += value;
Dataset->FieldByName("FIELDNAME")->AsSomething -= value;

and it does not seemed to be related to TClientDataSet, just and TDataset and
descendants.
I have reproducable case with simple Paradox table.
MemProof detects this leak.

Girts wrote:
> 
> Hi,
> I am using TClient DataSet to store a results of calculations to be used in
> reports, etc. I have noticed program memory usage increase, when
> TClientDataSet is updated many times (thousands). I created a small example
> to demonstrate the problem. CDS is a TClientDataSet containing only one
> integer data field Aaa.
> 
>   CDS->CreateDataSet();
>   CDS->LogChanges = false;
>   for ( int i = 1; i < 10000; i++) {
>      CDS->Append();
>      CDS->FieldByName("Aaa")->AsInteger = i;
>      CDS->Post();
>   }
>   for ( int i = 1; i <= 10; i++) {
>       CDS->First();
>       while (!CDS->Eof) {
>          CDS->Edit();
>          CDS->FieldByName("Aaa")->AsInteger =
> CDS->FieldByName("Aaa")->AsInteger + 1;
>          CDS->Post();
>          CDS->Next();
>       }
>   }
> 
> Basically in a second for loop (on update of a field value) program memory
> usage increases by 64Kb per loop according to NT task manager. I tried this
> on 2 NT PC's and one Win98...
> I tested the same example with CB5 trial and it works correctly (no memory
> increase reported). Is this a known problem?
> Also I have a similar effect using statement like
>   CDS->FieldByName("Aaa")->AsInteger += 1;
> increasing memory usage as opposed to (which does not)
>   CDS->FieldByName("Aaa")->AsInteger = CDS->FieldByName("Aaa")->AsInteger +
> 1;
> This problem still exists in CB5 trial as well.
> 
> I am considering swithing to kbMemTable to use as a temporary dataset, but
> my trust in TClientDataSet, which I like a lot is kind of damaged...
> I am using CBuilder4 with Service Pack 2.
> Any solutions?
> 
> Girts
Technical Details
Message-ID: <38FBAD28.8DC5545B@san.rr.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8cv4sm$mj41@bornews.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fcd2b,49a90407f34ccd9a
X-Google-Attributes: gidfcd2b,public
From: "Michael A. Feinstein" <mfs@san.rr.com>
Subject: Re: Memory usage increase using TClientDataSet as a local temporary  dataset
Date: 2000/04/17
Message-ID: <38FBAD28.8DC5545B@san.rr.com>
X-Deja-AN: 612475028
Content-Transfer-Encoding: 7bit
References: <8cv4sm$mj41@bornews.borland.com>
X-Accept-Language: en
Content-Type: text/plain; charset=koi8-r
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Reply-To: mfs@san.rr.com
Newsgroups: borland.public.cppbuilder.database.multi-tier