If you’re hitting memory errors with Unity, you’ll really hit them with Unreal. I don’t even have the Editor open, I only open it when I’m not editing the code (called directly from Rider), as you actually compile part of the Editor’s code every time you compile.
Memory Allocation is better than it used to be. Pointers have one distinct advantage…
In C++, if you have a reference type (a class) then you’re generally dealing with a pointer, and you have to mark it as such with MyClass* or a special wrapper class. Accessing a member is generally done with a ->. If you have a value type (struct, or primitive), then you generally are passing a copy of the item. Accessing a member is with the . instead of → In either case, it’s clear when reading the code because of the way we access it…
In C#, the good news is you don’t have to worry about it, Reference types and Value types look exactly the same. No de-referencing because the . takes care of it for you, even though it looks like a struct accessor…
This can actually lead to some dangerous situations…
If I have a method:
public void Oops(List<int> importantList, int importantNumber)
In the calling function, the list passed to the method will be cleared! The number passed to the function will be unchanged, because the List was a reference value, you’re working on the real McCoy, and the int was just a copy, you can do whatever you want with it.
In C++, you would know by the header that you were working on a reference value
void Ooops(USomeSillyObject* SomeSillyObject, int importantValue);
You can tell the first one is a reference value, so be careful with it.