In last week’s tips for using collections like List<T>
, we saw how struct types are sometimes boxed resulting in GC allocations. This week we’ll see how to avoid boxing and learn some of the clever tricks that .NET collection types use to make this possible.
Posts Tagged boxing
Collection types like List<T>
and Dictionary<TKey, TValue>
are fundamental tools in C#. Sadly, I keep seeing the same misuses of them in codebase after codebase. Today we’ll look at the top 5 problems and learn how to easily avoid them!
Today we continue looking at the C++ that IL2CPP generates for our C# code by calling various types of functions and using boxing and unboxing. Just how much performance overhead do these entail? Read on to find out!
Value types like int
, structs, and enums seem simple, but much of what we think we know about them just isn’t true. This article explores how value types actually work in C# and uses that knowledge to improve how they’re implemented in the C++ scripting system.
The GitHub project is closing in on supporting all the “must have” features. Today’s article tackles “boxing” and “unboxing” so our C++ game code will be able to convert types like int
into an object
and then convert an object
back into an int
. Usually we want to avoid this because it creates garbage for the GC to later collect and ruins type safety, but sometimes an API like Debug.Log
insists that we pass it an object
. Read on to see how to use boxing and unboxing in C++!
Sometimes it seems like Unity programming is a minefield. Plenty of innocuous-looking code secretly creates garbage and eventually the GC runs and causes a frame hitch. Today’s article is about some of those less-obvious ways to create garbage.