As already mentioned, in C ++ you have to consider ownership. However, the 3D networked multi-user FPS I'm working on now has the official rule, "No new or delete." It uses only generic and unique pointers to determine ownership, and raw pointers extracted from them (using .get() ) wherever we need to interact with the C API. The performance drop is not noticeable. I use this as an example to illustrate a minor performance hit, since games / simulations usually have the most stringent performance requirements.
It also significantly reduced the time spent debugging and fixing memory leaks. A theoretically well-designed application will never run into these problems. In real life, working with deadlines, legacy systems, or existing game engines that were poorly designed, however, they are inevitable in large projects like games ... if you don't use smart pointers. If you need to dynamically allocate, there is not enough time to develop / rewrite the architecture or debug problems associated with resource management, and you want to remove it from the ground as quickly as possible, smart pointers are a way to go and not incur a noticeable execution cost even in large games.
source share