stlsizeof.cc
Displaying memory usage in bytes.
Filling data structures with 1024 elements and reporting the per element memory usage.
memory usage per element of a vector<uint32_t> : 4
memory usage per element of a list<uint32_t> : 24
memory usage per element of a deque<uint32_t> : 4.64062
memory usage per element of an unordered_set<uint32_t> : 29.6016
memory usage per element of a set<uint32_t> : 40
Comments :
This is an optimistic estimate: the overhead of the data structure and the allocations is ignored.
Because the per-value overhead might be fixed, the results might be less dramatic with larger elements, such as long strings.
|
|