Calculating the size of a std::queue<Mat>

Working in OpenCV 4.5, C++, Visual Studio 2017, MFC, Windows 10

I am pre-processing video frames and storing them to a std::queue for later use. The bigger the queue is allowed to be the more efficient my program will be.

My question is how much memory is being taken up by this queue. I have read that a good way to measure the size in bytes of a Mat is using the formula

size_t sizeInBytes = mat.step[0] * mat.rows;

Using that formula on a Mat that has 1080 rows, 1920 columns, and 3 channels I get a value of 6220800 bytes (5.9 MB). If I multiply that by the 200 frames that I have stored in the queue on my test machine I end up with 1186.52 GB. That does not sound right. My machine has 32 GB RAM. Is the std::queue being written to hard drive? Or am I wrong in how I calculated the size in bytes of a Mat?

Ed

200 x 6Mb == 1200 Mb , still a lot…

lol, no.

I did my math wrong. Just counting rows, columns, and channels we get 1080 X 1920 X 3 = 6220800 which is (rounded) 6MB and X 200 frames is 1200 MB as you say. I had multiplied the bytes by 200 and had gotten 1,244,160,000 bytes. Divided by 1024 gave me 1,215,000 MB (this should be KB not MB) which, divided again by 1024 converted to 1186 GB and I KNEW that had to be wrong. I see I went from KB to GB and not KB to MB to GB. Always something stupid

Thanks again.

Ed