C++ (Qt)for (int i = 0; i < 1024; ++i) { void * temp = malloc(i * 1024 * 1024); std::cerr << i << " Mb" << std::endl; free(temp);} std::cerr << "done";
C++ (Qt) QVector<char> tst2(1024 * 1024 * (512));std::cerr << "Allocate 1Gb" << std::endl;QVector<char> tst(1024 * 1024 * (1024));
C++ (Qt)#include <iostream>#include <iomanip>#include <QVector> using namespace std; int main(){ { cerr << "Allocate 1Gb" << endl; QVector<char> tst( 1024 * 1024 * 1024 ); } { cerr << "Allocate..." << endl; size_t it = 0; QVector<char> vec; QVector<char> chunk( 1024 * 1024 ); for(;;) { vec += chunk; cerr << dec << it++ << " Mb" << " addr = " << hex << reinterpret_cast<const void*>( vec.constData() ) << " size = " << dec << vec.capacity() << endl; } }}
C++ (Qt)#include <iostream>#include <iomanip> using namespace std; int main(){ { cerr << "Allocate..." << endl; size_t it = 1; char *oldPtr = new char[ it * 1024 * 1024 ]; for(;;) { size_t sz = ++it * 1024 * 1024; char *newPtr = new char[ sz ]; delete[] oldPtr; oldPtr = newPtr; cerr << dec << it << " Mb" << " addr = " << hex << reinterpret_cast<const void*>( oldPtr ) << " " << sz << endl; } }}