Starting a C++ project. Should I worry about freeing dynamic allocated memory?

c++, garbage-collection, memory-management

Solution

Where should I read about this?

Herb Sutter's Exceptional C++ and Scott Meyers's More Effective C++ are both excellent books that cover the subject in detail.

There is also a lot of discussion on the web (Google or StackOverflow searches for "RAII" or "smart pointer" will no doubt yield many good results).

Is this a valuable replacement for proper `delete` C++ functionality?

Absolutely. The ability not to worry about cleaning up resources, especially when an exception is thrown, is one of the most valuable aspects of using RAII and smart pointers.

Problem

I am pretty proficient with C, and freeing memory in C is a must. However, I'm starting my first C++ project, and I've heard some things about how you don't need to free memory, by using shared pointers and other things. Where should I read about this? Is this a valuable replacement for proper `delete` C++ functionality? How does it work? EDIT I'm confused, some people are saying that I should allocate using `new` and use smart pointers for the deallocation process. Other people are saying that I shouldn't allocate dynamic memory in the first place. Others are saying that if I use new I also have to use delete just like C. So which method is considered more standard and more-often used?

Original source

Related problems