5 ms·
How in the world would you get full memory management without garbage collection in c++?
by tigershark 8y ago
How in the world would you get full memory management without garbage collection in c++?
- fsloth 8y agoThe author above is referring to reference counting. And no, there is nothing to capture circular refernce.
- tigershark 8y agoYes, I thought about that, but ARC is a form of garbage collection, so you can’t have automatic memory management in C++ without garbage collection, unless I’m missing something quite fundamental...
- corysama 8y agoOK. ok. "full" was an overstatement. You got me. The point is that you can write large programs without ever calling delete or free() and still not leak memory. True, it's not completely general nor impossible to screw up. You still need to be aware of issues like circular references. And, using shared_ptr would make lifetime as ambiguous as a Java reference. But, if you keep everything a DAG of containers and unique_ptrs, not only will your memory thank you, your coworkers will too.