benibela/internettools

Infinity memory consumption

SergeyPyankov opened this issue · 2 comments

I use latest Lazarus 1.8.2 with FPC 3.0.4 on Windows and create simple test application with the one button:

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

uses
  simpleinternet;

procedure TForm1.Button1Click(Sender: TObject);
var
  S: string;
begin
  S := process('https://github.com/benibela/internettools', '//div[1]').toString;
end;

end.

After each button click app increases the memory consumption by about 1 Mb, i. e. 50 clicks lead to +45 Mb.

There is no garbage collection for documents yet

You need to call freeThreadVars to free all that memory at once

With 98c6217 all documents are reference counted

but now you need to be careful when using TTreeNode