Class TLeakReport
Unit
Declaration
type TLeakReport = class(TInterfacedObject, ILeakReport)
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
- TInterfacedObject
- TLeakReport
Overview
Methods
| Public | constructor Create; |
| Public | destructor Destroy; override; |
| Public | class function New(ABuider: ICommandBuilder; const AProjectSource: string): ILeakReport; |
| Public | procedure SetCommandBuilder(ABuilder: ICommandBuilder); |
| Public | function AddItem(AItem: ILeakItem): ILeakItem; |
| 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): ILeakReport; |
Properties
| Public | property Executable: string read FExecutable write FExecutable; |
| Public | property ProjectSource: string read FProjectSource write FProjectSource; |
| Public | property LeakData: TArray<ILeakItem> read GetLeakData; |
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): ILeakReport; |
|
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 | procedure SetCommandBuilder(ABuilder: ICommandBuilder); |
|
Set the command builder used to produce the report | |
| Public | function AddItem(AItem: ILeakItem): ILeakItem; |
|
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): ILeakReport; |
|
Parses the contents of the trace file generated by the HeapTrace unit. Groups the information into a TLeakItem list.
Parameters
| |
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<ILeakItem> read GetLeakData; |
|
Array of TLeakItem that is generated after calling ParseHeapTrace method. | |
Generated by PasDoc 1.0.4.