Recent

Author Topic: [Solved] Filter dataset, memory growing up?  (Read 782 times)

lainz

  • Hero Member
  • *****
  • Posts: 3139
    • Lainz
[Solved] Filter dataset, memory growing up?
« 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?
« Last Edit: June 25, 2019, 04:09:44 am by Lainz »

valdir.marcos

  • Hero Member
  • *****
  • Posts: 735
Re: Filter dataset, memory growing up?
« Reply #1 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?

lainz

  • Hero Member
  • *****
  • Posts: 3139
    • Lainz
Re: Filter dataset, memory growing up?
« Reply #2 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.
« Last Edit: June 23, 2019, 02:01:24 am by Lainz »

lainz

  • Hero Member
  • *****
  • Posts: 3139
    • Lainz
Re: Filter dataset, memory growing up?
« Reply #3 on: June 23, 2019, 05:10:08 pm »

lainz

  • Hero Member
  • *****
  • Posts: 3139
    • Lainz
Re: Filter dataset, memory growing up?
« Reply #4 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.

lainz

  • Hero Member
  • *****
  • Posts: 3139
    • Lainz
Re: [Closed] Filter dataset, memory growing up?
« Reply #5 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