# IRefCounted

> An interface for shared component types to inherit from. Whenever a IRefCounted shared component is added to a world, its Retain() method will be invoked. Similarly, when removed from a world, its Release() method will be invoked. This interface can be used to safely manage the lifetime of a shared component whose instance data is shared between multiple worlds.

## Definition

* **Type:** Interface
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

```csharp
public interface IRefCounted
```

## Methods

| Method                                                                           | Description                                                                      |
| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| [Release](/engine/7000.0/script-reference/unity/entities/irefcounted/release.md) | Called when a world has the last instance of a IRefCounted type removed from it. |
| [Retain](/engine/7000.0/script-reference/unity/entities/irefcounted/retain.md)   | Called when a world has a new instance of a IRefCounted type added to it.        |

## Delegates

| Delegate                                                                                                       | Description                                                                                         |
| -------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| [IRefCounted.RefCountDelegate](/engine/7000.0/script-reference/unity/entities/irefcounted/refcountdelegate.md) | Delegate method used for invoking Retain() and Release() member functions from Burst compiled code. |
