🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.multi-tier
3 messages
3 total messages Started by Girts Tue, 11 Apr 2000 00:00
Memory usage increase using TClientDataSet as a local temporary dataset
#1229
Author: Girts
Date: Tue, 11 Apr 2000 00:00
43 lines
2111 bytes
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
Re: Memory usage increase using TClientDataSet as a local temporary dataset
#1231
Author: Kim Madsen
Date: Thu, 13 Apr 2000 00:00
83 lines
3188 bytes
Hi,

I believe the problem has to do with versioning of TClientDataset. Every
change you make probably adds a new version of the record. Only when you
clearout the table or 'resolve' the changes, the versions are deleted.

In TkbmMemTable you can control just how many versions should be kept on
change (1 or all) or if versioning should be used at all.

You definitely ought to join the memtable community at:
http://www.onelist.com/community/memtable to checkout the latest
versions (2.38 is latest release) and participate in the discussions of
using and enhancing it.

best regards

Kim Madsen
kbm@optical.dk
Author of TkbmMemTable

In article <8cv4sm$mj41@bornews.borland.com>,
  "Girts" <girts@vivasport.lv> 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
>
>

--
Kim Madsen
kbm@optical.dk


Sent via Deja.com http://www.deja.com/
Before you buy.
Re: Memory usage increase using TClientDataSet as a local temporary dataset
#1233
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads