Problem in Qvector initialization
-
wrote on 7 Jun 2017, 10:01 last edited by
Hi
I face to amazing problem !!!
can any body say me the reason of this reaction ?
when I wrote first line code , and debug my code this line allocated 15GB RAM but when replace number of array with scientific symbol this problem solved and my app work regularly .//Qvector initialization 1- QVector <QByteArray> vector(200000000); // Replace number with scientific symbol 2- QVector <QByteArray> vector(2e8);
-
Hi
I face to amazing problem !!!
can any body say me the reason of this reaction ?
when I wrote first line code , and debug my code this line allocated 15GB RAM but when replace number of array with scientific symbol this problem solved and my app work regularly .//Qvector initialization 1- QVector <QByteArray> vector(200000000); // Replace number with scientific symbol 2- QVector <QByteArray> vector(2e8);
@Alexanov Interesting. Just tested on Windows 7: works and consumes only 12MB RAM. Are you sure it is not something else in your app?
What is your OS, compiler and Qt version? -
Hi
I face to amazing problem !!!
can any body say me the reason of this reaction ?
when I wrote first line code , and debug my code this line allocated 15GB RAM but when replace number of array with scientific symbol this problem solved and my app work regularly .//Qvector initialization 1- QVector <QByteArray> vector(200000000); // Replace number with scientific symbol 2- QVector <QByteArray> vector(2e8);
-
wrote on 7 Jun 2017, 10:32 last edited by VRonin 6 Jul 2017, 10:38
Tried with Qt 5.8 on Win7 and:
MSVC 2013 x64
Both versions allocate the correct amount of memory:(200000000 * sizeof(QByteArray)) + sizeof(QVector<QByteArray>)
= (200000000*8)+8 = ~1.6GBMSVC 2013 x32
Both versions allocate the correct amount of memory:(200000000 * sizeof(QByteArray)) + sizeof(QVector<QByteArray>)
= (200000000*4)+4 = ~800MB@koahnig said in Problem in Qvector initialization:
qDebug() << "vector size " << vector.size();
use
capacity()
instead ofsize()
in this case.What compiler/OS/architecture are you using?
-
@Alexanov Interesting. Just tested on Windows 7: works and consumes only 12MB RAM. Are you sure it is not something else in your app?
What is your OS, compiler and Qt version?wrote on 7 Jun 2017, 10:56 last edited by Alexanov 6 Jul 2017, 11:06
1/5