Sample Test Application

Here we will show a sample application which will demonstrate how FastMM can easily detect memory leaks and other memory defects. This application can be found under uniGUI demos folder \Framework\uniGUI\Demos\Desktop\FastMM.

1

Prepare FastMM files

Copy the required FastMM files into your application folder. The FastMM4 package includes many files, but these are the ones needed for debugging this application:

  • FastMM4.pas

  • FastMM4Messages.pas

  • FastMM4Options.inc

  • FastMM_FullDebugMode.dll

2

Include FastMM units in the DPR

Add the first two units to the DPR uses section. They should be the first files in the uses list.

Example DPR:

fmm.dpr
program fmm;

uses
  FastMM4,
  FastMM4Messages,
  Forms,
  ServerModule in 'ServerModule.pas' {UniServerModule: TUniGUIServerModule},
  MainModule in 'MainModule.pas' {UniMainModule: TUniGUIMainModule},
  Main in 'Main.pas' {MainForm: TUniForm};
3

Override FastMM options for uniGUI

Instead of editing FastMM4Options.inc directly, the demo provides a file named FastMM4uniGUIOptions.inc that collects settings meaningful for a uniGUI application and overrides default FastMM settings.

To include it, add this single line in FastMM4.pas right after the existing include:

FastMM4.pas (snippet)
unit FastMM4;

interface

{$Include FastMM4Options.inc}
{$Include FastMM4uniGUIOptions.inc} // <-- insert here

This change is already applied in the FastMM4.pas shipped with the demo project.

4

Enable map file generation

It is important to change the project Linking options and set Map File generation to Detailed.

While on some Delphi versions FastMM seems to work without this option enabled, on other Delphi versions you won't be able to get a stack trace report without a map file.

Since the demo project is deployed as a DPR file only, you need to manually adjust the above option after opening the project.

circle-info

Note: Make sure you have downloaded FastMM4 from its official repository and copied the required files into your application folder before proceeding.

clip0365