#define NUM_TEST (20 * 1024 * 1024)int i, j;QVector<int> theVector[100]; for (i = 0; i < 100; ++i) { theVector[i].reserve(NUM_TEST); for (j = 0; j < NUM_TEST; ++j) theVector[i].push_back(i); theVector[i].resize(2); theVector[i].squeeze();}
C++ (Qt) QVector<int> v1; v1.reserve( 100000 ); qDebug() << &v1[ 0 ] << &v1[ 99999 ]; v1.resize(2); v1.squeeze(); QVector<int> v2; v2.reserve( 90000 ); qDebug() << &v2[ 0 ] << &v2[ 89999 ];
C++ (Qt) const uint NUM_TEST = 1000 * 1024 * 1024; QVector<int> theVector; int *old_pos = 0; for( uint i = 0; i < NUM_TEST; ++i ) { theVector.push_back( i ); if( old_pos != &theVector[ 0 ] ) { old_pos = &theVector[ 0 ]; qDebug() << hex << qSetFieldWidth( 8 ) << i << &theVector[ 0 ]; } }
ASSERT failure in QVector<T>::operator[]: "index out of range", file /Library/Frameworks/QtCore.framework/Headers/qvector.h, line 337Abort trap
C++ (Qt) QVector<int> v1; QVector<int> v2; const int sizeV1 = 100000; const int sizeV2 = 60000; v1.resize( sizeV1 ); qDebug() << v1.size() << v1.capacity() << &v1[ 0 ] << &v1[ 0 ] + v1.capacity() * sizeof( int ); v1.resize( 2 ); v1.squeeze(); v2.resize( sizeV2 ); qDebug() << v2.size() << v2.capacity() << &v2[ 0 ] << &v2[ 0 ] + v2.capacity() * sizeof( int );
QVector<int> v1; v1.reserve( 100000 );for (int i = 0; i < 100 * 1000; ++i) v1.push_back(i);qDebug() << &v1[ 0 ] << &v1[ 99999 ];v1.resize(2); v1.squeeze(); QVector<int> v2; v2.reserve( 90000 );for (int i = 0; i < 90 * 1000; ++i) v2.push_back(i);qDebug() << &v2[ 0 ] << &v2[ 89999 ];
[Session started at 2009-09-17 10:57:06 +0300.]0x1c010 0x7da8c 0x7e010 0xd5e4c