[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Forms' (#lcl)

# TApplication.DoDecLCLRefcountToZero

Performs actions needed when the reference count for a TLCLComponent instance reaches 0 in the application.

## Declaration

Source position: forms.pp line 1591

`protected procedure TApplication.DoDecLCLRefcountToZero(`
`Sender: TObject`
`);`

## Description

DoDecLCLRefcountToZero is used in the ReleaseComponent method, and is assigned as the handler routine for the OnDecLCLRefcountToZero event when the LCLRefCount for the TLCLComponent has a value larger than 0.

DoDecLCLRefcountToZero ensures that the global OnDecLCLRefcountToZero handler in lclclasses.pp is unassigned and a call to FreeComponent is queued for asynchronous execution in the application. This is done to prevent an exception that occurs when the component is freed while a previous call to the OnDecLCLRefcountToZero handler is still in process.

## Version info

Added in LCL version 3.0.

## See also

TApplication.ReleaseComponent |  | Safely destroys a component used in the application.
TApplication.FreeComponent |  | Destroys all components marked for release.
TLCLComponent.LCLRefCount |  | The number of references to this component.
OnDecLCLRefcountToZero |  | Event handler signalled when a reference counted LCL component is released.