View Issue Details

IDProjectCategoryView StatusLast Update
0035756FPCDatabasepublic2019-06-25 07:59
ReporterlainzAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx64OSWindowsOS Version10
Product VersionProduct BuildFPC 3.3.1 
Target VersionFixed in Version3.3.1 
Summary0035756: TBufDataset Filter memory growing
DescriptionWhen you use the .Filter option in TBufDataset memory grows but never go back. This is noticeable in large datasets or when using the .Filter a lot of times.
Steps To ReproduceCompile and run attached demo, look at task manager of Windows to see how memory increases and then never goes back like any application does normally.
Additional InformationDiscussed in the forum
https://forum.lazarus.freepascal.org/index.php/topic,45797.msg324565.html#msg324565
TagsNo tags attached.
Fixed in Revision42283
FPCOldBugId
FPCTarget3.2.0
Attached Files

Activities

lainz

2019-06-23 17:09

reporter  

testbufdataset.zip (2,393 bytes)

Michael Van Canneyt

2019-06-23 19:24

administrator   ~0116876

There is no memory leak in bufdataset filter handling.
I rewrote your program to a command-line program:

program bufleak;

{$mode objfpc}
{$h+}

uses Classes, SysUtils, BufDataset, DB;

Var
  BufDataset1: TBufDataset;

var
  i : INteger;
  
begin
  BufDataset1:=TBufDataset.create(Nil);
  try
    BufDataset1.FieldDefs.Add('fYear',ftInteger);
    BufDataset1.CreateDataset;
    BufDataset1.Active := True;
    for i := 0 to 1000 do
      begin
      BufDataset1.Append;
      BufDataset1.FieldByName('fYear').Value := i;
      BufDataset1.Post;
      end;
   for I:=0 to 100 do
     begin
     BufDataset1.Filtered := False;
     BufDataset1.Filter := 'fYear = ' + IntToStr(i);
     BufDataset1.Filtered := True;
     BufDataset1.First;
     while not BufDataset1.EOF do
       BufDataset1.Next;
     end;
  finally
    BufDataset1.Free;
  end;
end.

Compile using mem leak checking:

home:~> fpc -ghl bufleak.pp
home:~> ./bufleak
Heap dump by heaptrc unit of /home/michael/bufleak
7194 memory blocks allocated : 24434109/24447016
7194 memory blocks freed : 24434109/24447016
0 unfreed memory blocks : 0
True heap size : 262144
True free heap : 262144
home:~>

As you can see: all memory is released.
Maybe the grid is to blame, or memory fragmentation.
But as long as there is no actual memory leak, all is well in TBufDataset itself.

lainz

2019-06-25 04:16

reporter   ~0116910

hi, i've seen that this was fixed today here
https://bugs.freepascal.org/view.php?id=35759

Please if you can, include this fix to 3.2 fixes?

Michael Van Canneyt

2019-06-25 07:59

administrator   ~0116913

Done.

Issue History

Date Modified Username Field Change
2019-06-23 17:09 lainz New Issue
2019-06-23 17:09 lainz File Added: testbufdataset.zip
2019-06-23 19:24 Michael Van Canneyt Assigned To => Michael Van Canneyt
2019-06-23 19:24 Michael Van Canneyt Status new => resolved
2019-06-23 19:24 Michael Van Canneyt Resolution open => no change required
2019-06-23 19:24 Michael Van Canneyt FPCTarget => -
2019-06-23 19:24 Michael Van Canneyt Note Added: 0116876
2019-06-25 04:16 lainz Status resolved => feedback
2019-06-25 04:16 lainz Resolution no change required => reopened
2019-06-25 04:16 lainz Note Added: 0116910
2019-06-25 07:59 Michael Van Canneyt Status feedback => resolved
2019-06-25 07:59 Michael Van Canneyt Resolution reopened => fixed
2019-06-25 07:59 Michael Van Canneyt Fixed in Version => 3.3.1
2019-06-25 07:59 Michael Van Canneyt Fixed in Revision => 42283
2019-06-25 07:59 Michael Van Canneyt FPCTarget - => 3.2.0
2019-06-25 07:59 Michael Van Canneyt Note Added: 0116913