What is the difference between std::make_shared<T> and std::shared_ptr<T>(new T) in terms of heap allocations and exception safety?

Last updated 21 June 2026

  • make_shared<T> does one heap allocation for object + control block (better locality). shared_ptr<T>(new T) does two.

  • With separate new, a call like f(shared_ptr<T>(new T), g()) can leak if g() throws before the owner is built. make_shared has no unmanaged window.

  • Trade-off: with make_shared the object's memory isn't freed until all weak_ptrs die, and it can't take a custom deleter.

  • https://utkrusht.ai/blog/cplusplus-interview-questions
  • https://roadmap.sh/questions/cpp
  • https://internshala.com/blog/cpp-coding-interview-questions/
All C++ interview questions