Class TLeakReport

Unit

Declaration

type TLeakReport = class(TObject)

Description

<sumary> This class aims to interpret the memory leak trace file and produce a simpler report summarizing enough information to locate the problem at its source. )

Hierarchy

Overview

Methods

Public constructor Create;
Public destructor Destroy; override;
Public class function New(ABuider: ICommandBuilder; const AProjectSource: string): TLeakReport;
Public function AddItem(AItem: TLeakItem): TLeakItem;
Public procedure CreateLeakItem(AContent: TStringList; AStart: Integer);
Public function GetNextStringOf(const AText, AField: string): string;
Public function AddRelativePath(const AFile: string): string;
Public procedure Output;
Public function ParseHeapTrace(const AContent: string): TLeakReport;

Properties

Public property Executable: string read FExecutable write FExecutable;
Public property ProjectSource: string read FProjectSource write FProjectSource;
Public property LeakData: TArray<TLeakItem> read FLeakData write FLeakData;

Description

Methods

Public constructor Create;

Class constructor that initializes arrays and control variables. Check factory method new as the best option.

Public destructor Destroy; override;

The class's destructor frees all TLeakItem instances created during parse.

Public class function New(ABuider: ICommandBuilder; const AProjectSource: string): TLeakReport;

It is the best way to create a new instance of the class, as it considers its dependencies.

A valid instance of ICommandBuilder. Basically it will be used to generate the output to the console considering the theme settings.)

The path to the source code, needed to find the files corresponding to the source code reported in the memory leak trace file. )

Public function AddItem(AItem: TLeakItem): TLeakItem;

Adds a new memory leak item to the report.

Public procedure CreateLeakItem(AContent: TStringList; AStart: Integer);

Scans the contents of the AContent variable to summarize the details of a memory leak reported in the trace file. If a memory leak is found then it added to the report calling AddItem method.

Public function GetNextStringOf(const AText, AField: string): string;

Considering the content of AText, it searches for the string AField, if successful, returns the value immediately to the right of that string. The returned value will be limited until it finds the next space or the end of the string.

Public function AddRelativePath(const AFile: string): string;

Given a filename, try to locate it recursively in the projects folder, then in the current directory. If the file is found, the relative path will be added to the file name.

Public procedure Output;

Prints a report using ICommandBuilder's Output Callback. This report will have data regarding possible memory leaks like size, source method and source code file with line number. If no leak was found, it will display a message indicating the same.

Public function ParseHeapTrace(const AContent: string): TLeakReport;

Parses the contents of the trace file generated by the HeapTrace unit. Groups the information into a TLeakItem list.

Parameters
AContent
Accepts the contents of the memory leak trace file. If an empty string is passed, the method will try to locate the heap.trc file in the test project's executable directory.

Properties

Public property Executable: string read FExecutable write FExecutable;

Test project excutable name.

Public property ProjectSource: string read FProjectSource write FProjectSource;

Path to test project source files

Public property LeakData: TArray<TLeakItem> read FLeakData write FLeakData;

Array of TLeakItem that is generated after calling ParseHeapTrace method.


Generated by PasDoc 0.16.0.