#include <QtCore/QCoreApplication>#include <iostream>#include <stdio.h>#define NUM_TEST (200LL * 1024 * 1024)int main(int argc, char *argv[]){ QCoreApplication a(argc, argv); int i; QList<int> theList; for (i = 0; i < NUM_TEST; ++i) theList.append(qrand()); printf("Press Enter 1\r"); getc(stdin); theList.erase(theList.begin() + NUM_TEST / 4, theList.begin() + NUM_TEST / 4 * 3); printf("Press Enter 2\r"); getc(stdin); return 0;}
#include <QtCore/QCoreApplication>#include <iostream>#include <stdio.h>#include <QVector>#define NUM_TEST (200LL * 1024 * 1024)int main(int argc, char *argv[]){ QCoreApplication a(argc, argv); int i; QVector<int> theVector; for (i = 0; i < NUM_TEST; ++i) theVector.append(qrand()); printf("Press Enter 1\r"); getc(stdin); theVector.resize(NUM_TEST / 2); printf("Press Enter 2\r"); getc(stdin); return 0;}
#define NUM_TEST (200LL * 1024 * 1024) int i, j; QVector<int> theVector[10]; for (i = 0; i < 10; ++i) { theVector[i].reserve(NUM_TEST); for (j = 0; j < NUM_TEST; ++j) theVector[i].append(1); theVector[i].resize(2); theVector[i].squeeze(); }
[Session started at 2009-09-14 13:11:02 +0300.]realloc(508) malloc: *** mmap(size=838864896) failed (error code=12)*** error: can't allocate region*** set a breakpoint in malloc_error_break to debug
C++ (Qt)#include <vector>... int i, j; std::vector<int> theVector[10]; for (i = 0; i < 10; ++i) { theVector[i].reserve(NUM_TEST); for (j = 0; j < NUM_TEST; ++j) theVector[i].push_back(1); theVector[i].resize(2); { std::vector<int> t; std::swap(theVector[i],t); theVector[i]=t; std::cout << theVector[i].capacity() << std::endl; } }
C++ (Qt) QVector<int> *theVector1; QVector<int> *theVector2; theVector1 = new QVector<int>; theVector1->reserve(200*1024*1024); theVector1->squeeze(); delete theVector1; theVector2 = new QVector<int>; theVector2->reserve(200*1024*1024); delete theVector2;
C++ (Qt) QVector<int> *theVector1; QVector<int> *theVector2; theVector1 = new QVector<int>; theVector1->reserve(200*1024*1024); theVector1->squeeze(); theVector2 = new QVector<int>; theVector2->reserve(200*1024*1024); delete theVector1; delete theVector2;
C++ (Qt) sbw::Indices* theVector1; sbw::Indices* theVector2; theVector1 = new sbw::Indices; theVector1->maxCapacity(250*1024*1024); theVector1->minCapacity(); theVector2 = new sbw::Indices; theVector2->maxCapacity(250*1024*1024); delete theVector1; delete theVector2;