RTL.LeakReporting Sample

From RAD Studio XE2 Code Examples
Jump to: navigation, search

Language:

Contents

This sample demonstrates how to use the Delphi leak detection mechanism.

Location

You can find the Leak Reporting sample project at:

Description

This application creates a form with three buttons and a combo box. The combo box allows the user to choose whether the memory leaks will be reported or not when the application closes.

The first button, Leak a TObject, creates a new instance of TObject. Clicking this button prompts a notification when the application closes, if the Unexpected memory leaks will be reported on shutdown option is selected from the combo box.

The second button also creates a new instance of TObject but registers it as an expected memory leak, therefore no notification will be prompted when the application closes.

The third button creates a TObject instance, registers it as an expected memory leak, then it frees the allocated memory and unregisters the memory leak. Clicking this button will also not trigger a notification when the application closes.

How to Use the Sample

  1. Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open LeakTest.dproj.
  2. Press F9 or choose Run > Run.

Files

This project has one source file, LeakTestForm, which contains the class for the main form.

Classes

TfLeakTestForm, the class for the main form, creates and destroys TObject instances, registers and unregisters memory leaks, and sets whether memory leaks will be reported or not on application shutdown.

Implementation

Uses

See Also

Personal tools
Previous Versions