PDA

View Full Version : QString memory consumption



sicker
4th November 2011, 14:45
Heya,

i have some pretty strange problem with QString and QT Containers.
My program is loading strings and an incremental primary key from a database table and inserts them into a hash.

QHash<quint64, QString>

After the insert the original data gets freed. So i suppose a deep copy happens internally. With Windows it is no problem at all and the memory consumption is very low. But when i try it under Linux it uses up to 100mb for really small strings.
I have tried a hash with std::string and it works without any problem at all.

I tried to reproduce it in main() , but there does not seem to be a problem at all.

I would appreciate any hint ;-)

sicker
4th November 2011, 17:23
I have made some more tests.

basically i am retrieving data from a database. For each row an object gets allocated which saves all the attributes as members.

The Class returns QString for example and that QString gets added in the above-mentioned hash.


The following consumes way more memory:

QString temp = pTBReleaseEntry->getFileHash();


releaseIdToString.insert(pTBReleaseEntry->getReleaseId(), temp);



The following consumes way less memory:


QString temp(pTBReleaseEntry->getFileHash().toLatin1().data());

releaseIdToString.insert(pTBReleaseEntry->getReleaseId(), temp);


I suppose this is some QT issue, which i do not really understand. ;-)