I have a boost::multi_array of 3 dimensions
boost::multi_array<Struct, 3>* newArr = new boost::multi_array<Struct, 3>(boost::extents[x][y][z], boost::fortran_storage_order())
Is there method to calculate the size of newArr or should I just use
sizeof(Struct)*x*y*z ?
Would they be the same? (I expect the multi_array to have little bit of controller-data)
You should be able to use
Let me search a bit whether the documentation reveals an easier/more generic approach.
Also, I like to just not bother and use the output of e.g.
valgrind --tool=massifto know exactly what is allocated where. This would then also give the relevant results if you had, e.g.Here's sample output from Massif when using a Struct with just a
std::stringmember:This results in e.g. on my system 384,000,160 bytes, which is exactly what's printed when you add
std::cout << 300*400*400*sizeof(Struct)+sizeof(*newArr);