I'm trying to optimize memory usage in my code.
I found that some Qt containers have capacity(), reserve() and squeeze() functions for this purpose.
Making some tests I found a strange result (among normal ones!):
in some conditions I get capacity() < size().
If I understand correctly the documentation, capacity() should give the number of allocated items (which generally is greater than the number of inserted items, for speed reasons).

Qt Code:
  1. QHash< DataUniqueId, DrawItem* > m_lookupTable;
  2.  
  3. // Insert data into m_lookupTable
  4. for (...) {
  5. m_lookupTable.insert(..., ...);
  6. }
  7.  
  8. qDebug() << m_lookupTable.size() << m_lookupTable.capacity();
  9.  
  10. // No more insertions, so release any unused memory
  11. m_lookupTable.squeeze();
  12.  
  13. qDebug() << m_lookupTable.size() << m_lookupTable.capacity();
To copy to clipboard, switch view to plain text mode 

This is the output:
Qt Code:
  1. 500 521
  2. 500 257
To copy to clipboard, switch view to plain text mode 

As you can see, after the squeeze(), size() > capacity().
How can the number of allocated items be less than the number of real items?
Am I doing something wrong?

Thanks in advance,
Alessandro