#include <iostream>
#include <sstream>
#include <cmath>
int main() {
// Create a chunk of data that is 128 Mbs
int szDataChunk = pow(2, 27);
char* data = new char[szDataChunk];
//The number of times to add this chunk to a stream.
// So, 128 Mbs * 32 = 2^(27+5) = 2^32 = 4 GBs
int ntimes = pow(2, 5);
std::stringstream* m_stream = new std::stringstream();
for (int i = 0; i < ntimes; i++)
{
// Write the data to stream
m_stream->write(data, szDataChunk);
// See the size onscreen
std::cout << m_stream->tellp() << " bytes | "
<< m_stream->tellp() / (1024 * 1024) << " Mb \n";
}
return 0;
}