NTL Memory Usage
From Upp
Sometimes it can be useful to estimate the amount of memory needed for basic NTL containers.
Here are some general formulas you can use, in each formula T stands for the template variable in use:
Contents |
Vectors
Memory required = sizeof(T) * GetCount() * 1.33
In case the size of the template is dynamic, use the avarage. GetCount() is how many element are needed/used for the vector. And the expansion reserve is calculated by multiplying with 1.33.
Arrays
Memory required = sizeof(T) * GetCount() + (1.33 * sizeof(void *))
One should keep in mind that the elements are pointed to in an array, thus this container uses less memory.
Index
Memory required = sizeof(T) * GetCount() * 1.33 * Hash size
Index works almost the same as vectors, but adds a hash to each element. The hash size(StdHash<T>) is on average 20 bytes.
VectorMap / ArrayMap
Maps are basically the Index + Array / Vector.
