I have serialized a map using QDataStream and written the object into a file.
The serialized file size is 1.5mb when i deserialize it again and load the map into memory, the memory consumption was 300mb. I have used the same QDataStream to deserialize.
Can you let me know the reason why deserialization of the 1.5mb serialized object written to a file on disk took 300mb in the memory.
Serialization:
QMap< QString, QSet< QString > > myMap[100];
QSet<QString> mySet; // Assume it has some data in it.
QSet<QString> mySet1; // Assume it has some data in it.
MyMap.insert("a", mySet);
MyMap.insert("b", mySet1);
QFile f( strOutFile );
f.open(QIODevice::WriteOnly);
QDataStream streamOut( &f );
streamOut << myMap;
Deserialization:
QFile f(StrInFile);
QMap< QString, QSet< QString > > InMap[100];
QDataStream streamIn( f, QIODevice::ReadOnly );
streamIn >> InMap[index];
I have checked the memory consumption using MEMORYSTATUSEX windows library. After deserializing, the memory consumed was 300 mb.
Thanks for the Help.