Recent

Author Topic: TATTabs memory leak  (Read 9183 times)

tom.tom

  • New Member
  • *
  • Posts: 43
Re: TATTabs memory leak
« Reply #15 on: July 23, 2021, 09:11:35 pm »
I'll prepare sample app for you to run and tell me if there is a leak at your end.

BTW - which OS and LAzarus version do you use?

Alextp

  • Hero Member
  • *****
  • Posts: 1376
    • UVviewsoft
Re: TATTabs memory leak
« Reply #16 on: July 23, 2021, 10:47:02 pm »
Lazarus 2.3.0 r65368M FPC 3.2.1 x86_64-linux-gtk2

tom.tom

  • New Member
  • *
  • Posts: 43
Re: TATTabs memory leak
« Reply #17 on: July 26, 2021, 12:32:47 pm »
I use older version - Lazarus 1.8, FPC 3.0.4 and Windows and OSX.

Could you check if this simple code reports memory leaks when run and closed in your environment (tick the 'use heaptrc' in project options)?

In my case it reports the leak in unit1 line 40.


Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, attabs;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     ATTabs1: TATTabs;
  16.     procedure FormCreate(Sender: TObject);
  17.   private
  18.  
  19.   public
  20.  
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.lfm}
  29.  
  30. { TForm1 }
  31.  
  32. procedure TForm1.FormCreate(Sender: TObject);
  33. var
  34.   iTmp : Integer;
  35.   data : TATTabData;
  36. begin
  37.   for iTmp := 0 to Pred(ATTabs1.TabCount) do
  38.   begin
  39.     data := ATTabs1.GetTabData(iTMp);
  40.     data.TabCaption := Format ('Tab #%d', [iTmp]);
  41.   end;
  42. end;
  43.  
  44. end.
  45.  
  46.  

Code: Pascal  [Select][+][-]
  1. object Form1: TForm1
  2.   Left = 741
  3.   Height = 332
  4.   Top = 405
  5.   Width = 625
  6.   Caption = 'Form1'
  7.   ClientHeight = 332
  8.   ClientWidth = 625
  9.   OnCreate = FormCreate
  10.   LCLVersion = '1.8.0.6'
  11.   object ATTabs1: TATTabs
  12.     Left = 0
  13.     Height = 35
  14.     Top = 0
  15.     Width = 625
  16.     Align = alTop
  17.     ParentColor = False
  18.     Tabs = <    
  19.       item
  20.       end    
  21.       item
  22.       end    
  23.       item
  24.       end    
  25.       item
  26.       end>
  27.     DoubleBuffered = True
  28.     OptButtonLayout = '<>,v'
  29.     OptShowModifiedText = '*'
  30.     OptShowPinnedText = '!'
  31.     OptHintForX = 'Close tab'
  32.     OptHintForPlus = 'Add tab'
  33.     OptHintForArrowLeft = 'Scroll tabs left'
  34.     OptHintForArrowRight = 'Scroll tabs right'
  35.     OptHintForArrowMenu = 'Show tabs list'
  36.     OptHintForUser0 = '0'
  37.     OptHintForUser1 = '1'
  38.     OptHintForUser2 = '2'
  39.     OptHintForUser3 = '3'
  40.     OptHintForUser4 = '4'
  41.   end
  42. end
  43.  
« Last Edit: July 26, 2021, 12:36:09 pm by tom.tom »

Alextp

  • Hero Member
  • *****
  • Posts: 1376
    • UVviewsoft
Re: TATTabs memory leak
« Reply #18 on: July 26, 2021, 01:44:24 pm »
Yes I see that memleak, in this project. I looked in the code but couldn't find the reason, sorry. E.g. in this project (4 tabs) I see that TATTabData.Destroy is called 4 times on exiting.

tom.tom

  • New Member
  • *
  • Posts: 43
Re: TATTabs memory leak
« Reply #19 on: July 26, 2021, 03:13:10 pm »
What's that 37 bytes block? Is this TATTabData size?

Please notice, that if you change the dynamic string (Format(...)) to static - i.e.

data.TabCaption := 'Tab';

...there will be no leak reported.

It may be something to do with tracking that string reference not the TATabData as a whole....

Alextp

  • Hero Member
  • *****
  • Posts: 1376
    • UVviewsoft
Re: TATTabs memory leak
« Reply #20 on: July 26, 2021, 06:10:38 pm »
Then it means that TabCaption value makes a leak. But again, I cannot find the reason..

Alextp

  • Hero Member
  • *****
  • Posts: 1376
    • UVviewsoft
Re: TATTabs memory leak
« Reply #21 on: September 10, 2021, 04:40:05 pm »
It (mem leak) was fixed just now. See https://github.com/Alexey-T/ATFlatControls/issues/73

Updated in github.

 

TinyPortal © 2005-2018