3 ms·
Manual memory management is for the birds. Use something like Boost's shared pointers and you never need to worry about it.
by maxtaco 16y ago
Manual memory management is for the birds. Use something like Boost's shared pointers and you never need to worry about it.
- api 16y agoYou can also often make clever use of RAII and STL container classes and do memory management that way.
- Peaker 16y agoThat's not entirely honest. A) You still have to worry about it when interfacing with libraries that use plain pointers B) Shared pointers incur runtime penalties (larger data pushes things off the cache, spurious inc/dec-refs messing said cache. If you don't care about that, why do you use a language like C++ in the first place? C) Reference counting is a poor form of automatic memory management, you still have to worry about cycles, and use weak references or such to break the cycles.