exilon / QuickLogger

Powerful and flexible library for logging on files, console, memory, email, rest, eventlog, syslog, slack, telegram, redis, logstash, elasticsearch, influxdb, graylog, Sentry, Twilio, ide debug messages and throw events for Delphi/Firemonkey/freepascal/.NET (Windows/Linux/OSX/IOS/Android).
Apache License 2.0
381 stars 84 forks source link

FastMM4 states there are memory leaks #111

Open vesnx opened 7 months ago

vesnx commented 7 months ago

Hi,

Mybe I am doing it wrong but I am trying to have the logs flush and so I made a method:

implementation

uses
  Quick.Logger,
  Quick.Logger.Provider.Files,
  Quick.Logger.ExceptionHook;

procedure FinalizeLogger; stdcall;
var
  count: Integer;
begin
  Log('Logger shutdown', etInfo);
  // Force the logger to flush any buffered messages.
  if Assigned(Logger) then
  begin
    count := Logger.QueueCount;
    Log('There are %d log items in queue.', [count], etInfo);
  end;

  if Assigned(GlobalLogFileProvider) then
  begin
    GlobalLogFileProvider.Drain;
    GlobalLogFileProvider.Stop;
  end;
end;

procedure FinalizeLogger; stdcall;
var
  count: Integer;
begin
  Log('Logger shutdown', etInfo);
  // Force the logger to flush any buffered messages.
  if Assigned(Logger) then
  begin
    count := Logger.QueueCount;
    Log('There are %d log items in queue.', [count], etInfo);
  end;

  if Assigned(GlobalLogFileProvider) then
  begin
    GlobalLogFileProvider.Drain;
    GlobalLogFileProvider.Stop;
  end;

end;

In my test I initialize and Finalize the log to make sure i capture it all:

  [TestFixture]
  EncyptionTest = class
  public
      [Setup]
    procedure Setup;
    [TearDown]
    procedure TearDown;
    [Test]
    procedure DeriveKeyFromPasswordTest;
    [Test]
    procedure DeriveSameKeyFromPasswordTest;
    [Test]
    procedure RoundTripTest;
  end;

procedure EncyptionTest.Setup;
begin
        InitializeLogger;
end;

procedure EncyptionTest.TearDown;
begin
  FinalizeLogger;
end;

When the test ends I get a warning box image

I enabled the detail logs and attached them

WalterNativeTests_MemoryManager_EventLog.txt

Am I doing something wrong, what am I missing?

exilon commented 1 week ago

Are you using it in a dll?

vesnx commented 1 week ago

Yes

exilon commented 1 week ago

Could you show me InitializeLogger function code?

vesnx commented 1 week ago

I have already removed the component, it has been quite some time that I reported it.