Lazarus

Programming => Databases => Topic started by: lainz on June 21, 2019, 12:49:47 am

Title: [Solved] Filter dataset, memory growing up?
Post by: lainz on June 21, 2019, 12:49:47 am
I have a dataset (Offers: TBufDataset;) where I have stored all "discounts & offers".

Offers.Filter := 'type = 0'
Offers.Filtered := True;

We have 9 kind of offers. The dataset is Filtered to look for the kind of offer, say offer type 0, offer type 1, and so on.

That procedure grows a lot the memory usage of the program every time is called. If I remove the filter lines, saying there are no offers, there is no leak.

It can be that filtering can cause memory grow, but no memory leak is found at the end of the program?
Title: Re: Filter dataset, memory growing up?
Post by: valdir.marcos on June 22, 2019, 06:29:27 pm
I have a dataset (Offers: TBufDataset;) where I have stored all "discounts & offers".
Code: Pascal  [Select][+][-]
  1. Offers.Filter   := 'type = 0'
  2. Offers.Filtered := True;
We have 9 kind of offers. The dataset is Filtered to look for the kind of offer, say offer type 0, offer type 1, and so on.
That procedure grows a lot the memory usage of the program every time is called. If I remove the filter lines, saying there are no offers, there is no leak.
It can be that filtering can cause memory grow, but no memory leak is found at the end of the program?
Could you provide a small sample project?
Title: Re: Filter dataset, memory growing up?
Post by: lainz on June 23, 2019, 01:52:16 am
Sure, here is a test project that shows the memory growing bug.

On my machine is about 100 kb per second the quantity of memory that grows and then never comes back (looking at the task manager on Windows 10).

Edit: to see memory growing faster, increase the number of records generated to 10000. But take into account that maybe you need to kill the application then.
Title: Re: Filter dataset, memory growing up?
Post by: lainz on June 23, 2019, 05:10:08 pm
Reported in bugtracker
https://bugs.freepascal.org/view.php?id=35756
Title: Re: Filter dataset, memory growing up?
Post by: lainz on June 23, 2019, 11:15:58 pm
Well it was solved as 'Memory Fragmentation' or 'blame the DBGrid'. With no DBGrid it still increases memory, so it must be the first choice.

I close this since no one will fix it, because "there are no leaks", but memory increases anyways, so better not use filter like I'm doing in the example.
Title: Re: [Closed] Filter dataset, memory growing up?
Post by: lainz on June 25, 2019, 04:09:28 am
Reopen.

Thanks to BrunoK for opening a new issue with a fix
https://bugs.freepascal.org/view.php?id=35759
TinyPortal © 2005-2018