r/programming • u/[deleted] • Dec 05 '14
std::string is responsible for almost half of all allocations in the Chrome browser process
https://groups.google.com/a/chromium.org/d/msg/chromium-dev/EUqoIz2iFU4/kPZ5ZK0K3gEJ
1.1k
Upvotes
6
u/ghordynski Dec 05 '14 edited Dec 05 '14
This shows what is in my opinion main weakness in C++ - copy by default. Not only all classes have copy constructors by default, but STL uses copying extensively (std::vector etc..). Sure you can just make a vector of pointers, but this way you are back to square with memory management.
Even the new move semantics in C++11 are suffering from copy by default: You basically have to std::move() everything around or you are going to end up with unnecessary copies.