The terrible C++ garbage collector crash by improper lambda usage -- UE C++ Tutorial

Published March 23, 2024
Advertisement


Perhaps the most common way someone learning to write C++ in Unreal accidentally crashes the game.

Without safe mark up, you can create a ticking time bomb for a crash. C++ can be dangerous if not careful. Blueprint ensures this type of situation isn't possible, but with C++ it is on you to ensure your safely accessing and protecting your memory. By putting the macro UPROPERTY() above your variables to unreal types, the GC becomes aware of the pointer and will manage it. But without it, you create a situation where the GC will free the object, but be unaware to update the pointer to nullptr. Meaning you will have a dangling pointer. At best this null pointer will crash the game. At worst, it will corrupt memory and the game will keep on running with invalid memory. Wrecking incomprehensible and inconsistent issues on the game with undefined behavior.

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement