Wyciek pamięci w TDirMonitor

0

Wiem gdzie jest wyciek (zaznaczone w kodzie poniżej), ale nie potrafię tego poprawić, a mianowicie:

Jest to część z komponentu TDirMonitor do informowania o wszelkich zapisach, odczytach na dysku.

  TDirMonitor = class(TComponent)
  protected
    FDir:string;

    Mon:TProcessMonitor;  // <--------- moduł

    FEventChange: TEventChange;
    FActive: Boolean;
    procedure W_FActive(Value: boolean);
    procedure Loaded; override;
    procedure MakeMask;
  public
    FCompletionPort: Integer;
    FOverlapped: TOverlapped;
    FPOverlapped: POverlapped;
    FBytesWrite: DWORD;
    FNotificationBuffer: array[0..4096] of Byte;
    FHandle: integer;
    FWatchSubtree: boolean;
    FFilter: DWORD;
    FFilter_flag: TFilter;
    FActionFilter_flag: TActionFilter;

    constructor Create(Owner:TComponent); override;
    destructor Destroy;override;
    procedure RecibirEvento;
  published
    property Directory: string read FDir write Fdir;
    property WatchSubtree: boolean read FWatchSubtree write FWatchSubtree default false;
    property FilterNotification: TFilter read FFilter_flag write FFilter_flag;
    property FilterAction: TActionFilter read FActionFilter_flag write FActionFilter_flag;
    property OnChange: TEventChange read FEventChange write FEventChange;
    property Active: boolean read FActive write W_FActive default false;
  end;

//...

constructor TDirMonitor.Create(Owner: TComponent);
begin
  inherited;
  FPOverlapped := @FOverlapped;
  self.FCompletionPort:=0;
  self.FDir:='c:\';
  self.FFilter_flag:=[nfFILE_NAME];
  self.FActionFilter_flag := [faADDED, faREMOVED, faMODIFIED, faRENAMED_OLD_NAME, faRENAMED_NEW_NAME];
  Mon := TProcessMonitor.Create(self);  { <----------------- TUTAJ WYCIEK}
end;

destructor TDirMonitor.Destroy;
begin
 Mon.Terminate;
 
 inherited;
end;

//... dalsza część kodu nie znacząca

Oraz moduł TProcessMonitor w który nie jest zwalniany

unit ProcessMonitor;

interface

uses
  Classes, Windows, SysUtils;

type
  TProcessMonitor = class(TThread)
  private
    { Private declarations }
  protected
    FProRef: TComponent;
    procedure Execute; override;
    procedure SendEvent;
  public
    FHandle: integer;
    constructor Create(ProRef: TComponent); overload;
  end;

implementation

{ TMonitor }

uses DirMonitor;

constructor TProcessMonitor.Create(ProRef: TComponent);
begin
 Self.Create(True);
 Self.FProRef := ProRef;
 Self.Priority := tpNormal; //tpTimeCritical;
 FreeOnTerminate := True;
end;

//... dalsza część kodu nie znacząca
0
  1. skąd wiesz, że tam jest wyciek
  2. czym się on objawia
  3. pokaż execute wątku
0

Dokładniej to ten komponent:
http://eupload.pl/files/SASJSJCM/Directory%20ChangeNotify%20Monitor%201.0%20_bdb_.rar

Starałem się pokazać tylko to co potrzebne.
EurekaLog wskazuje wyciek pamięci na w/w linii w kodzie.

0

ściągnij sobie FastMM4 - on przynajmniej pokazuje co powoduje wyciek

1 użytkowników online, w tym zalogowanych: 0, gości: 1