# incrementalTimeSliceNanoseconds

> The target duration of a collection step when performing incremental garbage collection.

## Definition

* **Type:** Property
* **Namespace:** [UnityEngine.Scripting](/engine/6000.0/script-reference/unityengine/scripting.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public static ulong incrementalTimeSliceNanoseconds { get; set; }
```

### Remarks

When you enable incremental garbage collection, the garbage collector spreads the amount of work required to free unused memory across a number of steps. In any single step, the garbage collector limits itself to the length of time specified by `incrementalTimeSliceNanoseconds`. By spreading out the workload, incremental garbage collection can help your game achieve a smoother frame rate (when garbage-collection hiccups are a problem). Use the [Profiler](/engine/6000.0/script-reference/unityengine/profiling/profiler.md) to help identify whether garbage collection has an effect on frame rate smoothness.

The garbage collector might still choose to perform a regular, non-incremental collection cycle if your application runs low on memory or if the incremental steps cannot keep up with the garbage collection workload. Setting too short a time slice can be counterproductive in this regard and because each garbage collection step has a small amount of overhead. The default value of 3 ms (3000000 nanoseconds) is a good starting point and the selected duration should be always be significantly shorter than your target frame rate.

If you turn on Vsync by setting [QualitySettings.vSyncCount](/engine/6000.0/script-reference/unityengine/qualitysettings/vsynccount.md) greater than 0 or specify a frame rate with [Application.targetFrameRate](/engine/6000.0/script-reference/unityengine/application/targetframerate.md), Unity automatically uses any extra time remaining at the end of each frame for incremental garbage collection, regardless of the value of  [GarbageCollector.incrementalTimeSliceNanoseconds](/engine/6000.0/script-reference/unityengine/scripting/garbagecollector/incrementaltimeslicenanoseconds.md).

**Note**: The garbage collector uses the underlying platform timer, which can have a resolution as low as a whole millisecond. In other words, changing the value by a few nanoseconds might have no effect.

Enable incremental garbage collection in the [PlayerSettings](/engine/6000.0/script-reference/unityeditor/playersettings.md) for a project. You can check whether incremental garbage collection is enabled with IsIncremental.

You can manually trigger an incremental garbage collection step with [GarbageCollector.CollectIncremental](/engine/6000.0/script-reference/unityengine/scripting/garbagecollector/collectincremental.md).
