Incremental Garbage Collection in Unity 2019 – Overview

Channel:
Subscribers:
1,200,000
Published on ● Video Link: https://www.youtube.com/watch?v=5Fks2NArDc0



Garbage
Game:
Garbage (2021)
Duration: 4:56
40,896 views
1,005


Learn more about Incremental Garbage Collection: https://ole.unity.com/IncrementalGC

Check out Performance Tools on the Asset Store: https://ole.unity.com/performance-tools

Check out our webpage for courses: https://ole.unity.com/unitycourses

The C# language uses managed memory with automated garbage collection, meaning that it uses an automatic method of tracking objects in memory and releasing the memory of any object which is no longer needed (See our documentation for more info).

The benefit of this is that you generally don’t need to manually keep track of releasing any memory which you don’t need anymore because the garbage collector will automatically do that for you, which makes your work easier and also removes a big source of potential bugs. The downside is that the garbage collector takes some time to do its work, and this may happen in moments when you would rather not want to spend time on this.

Unity uses the Boehm–Demers–Weiser garbage collector which is a stop-the-world garbage collector, meaning that whenever it needs to perform garbage collection, it will stop the running program, and only resume normal execution once it has finished all its work. This can cause delays in the execution of the program at somewhat arbitrary moments, which can take anywhere between less than 1 and several 100 milliseconds, depending on how much memory the garbage collector needs to process and on the platform the program is running on.

Now, obviously, for real-time applications like games, this can become quite a big issue, as it isn’t possible to sustain a consistent frame rate as required for smooth animation if the program’s execution can be arbitrarily suspended by the garbage collector. These interruptions are also known as GC spikes, as they will show as spikes in an otherwise smooth profiler frame time graph. Usually, developers try to work around this issue by writing their code to avoid creating “garbage” memory while running the game, so the garbage collector has less work to do – but this isn’t always possible or easy.

Enter Incremental Garbage Collection. With Incremental GC, we still use the same Boehm–Demers–Weiser GC, but we run it in an incremental mode, which allows it to split its work into multiple slices. So instead of having a single long interruption of your program’s execution to allow the GC to do its work, you can have multiple, much shorter interruptions. While this will not make the GC faster overall, it can significantly reduce the problem of GC spikes breaking the smoothness of the animation by distributing the workload over multiple frames.




Other Videos By Unity


2019-05-31GDC 2019 - Unity Educator Breakfast: Immersive Learning at the University Level
2019-05-21The future of filmmaking: Creators developing with a real-time workflow
2019-05-20Unity 2019.2: GPU Lightmapper improvements
2019-05-03Making an FPS Game with Unity using the Asset Store!
2019-05-03Making 2D games with Unity for beginners – Ruby's Adventure
2019-04-25Making 3D games with Unity for beginners – John Lemon's Haunted Jaunt
2019-04-19Improve memory usage with the Memory Profiler in Unity (tutorial)
2019-04-19UIElements in Unity 2019.1
2019-04-19Octane 2019 for Unity: Cinematic & holographic media on the RNDR blockchain - Unity at GDC 2019
2019-04-19New sprite rigging and lighting for 2D - Unity at GDC 2019
2019-04-18Incremental Garbage Collection in Unity 2019 – Overview
2019-04-17HDRP in Unity 2019.1
2019-04-16Unity 2019.1 released: Burst Compiler, Lightweight Render Pipeline, Shader Graph and more
2019-04-15Visual Studio tips & tricks to boost your productivity - Unity at GDC 2019
2019-04-15Getting Started with the FPS sample - Unity at GDC 2019
2019-04-15A Guide to Stadia game development - Unity at GDC 2019
2019-04-15Introducing the new prefab workflow - Unity at GDC 2019
2019-04-15Get Started building world-class networked games with FPS Sample - Unity at GDC 2019
2019-04-12You look better as an alien cat: Multiuser MR with Unity & Magic Leap - Unity at GDC 2019
2019-04-12Beat Saber live: Best practices for creating award-winning VR experiences - Unity at GDC 2019
2019-04-11Reality vs illusion: What's achievable with real-time ray tracing



Tags:
Unity3d
Unity
Unity Technologies
Games
Game Development
Game Dev
Game Engine
unity
unity incremental garbage collection
unity incremental garbage collector
incremental garbage collection
incremental garbage collector
unity garbage collection
unity garbage collector
unity performance
unity 2019
unity2019
unity 2019.1
realtime
real-time
unity fps sample
unity fps
fps sample
fps sample unity
unity make a game
unity graphics
unity easy
easy



Other Statistics

Garbage Statistics For Unity

Currently, Unity has 40,896 views for Garbage across 1 video. Less than an hour worth of Garbage videos were uploaded to his channel, making up less than 0.01% of the total overall content on Unity's YouTube channel.