How-to works QPixmapCache ?!
-
Hi,
I use a QPixmapCache (I load several hundred QPixmap) for a big gain time, that works good when I launch my software.
But after several minutes, the QPixmapCache losts many QPixmap...
This is the same result if I wait without do anything or if I use it...
I don't understand why ?!
I have increase the cachelimit to 1go but, it the same thing...
Is it normal ?! Maybe haven't I understand something ?
Thanks et have a nice day !
EDIT : I have found this :
https://git-service.ait.ac.at/svs-lgpl/qt-4-for-sma-annotator/commit/c999065d5090a64192f96bed78c5224490409d6a
https://bugreports.qt.io/browse/QTBUG-31452
8 years ago... ?!And pyqt haven't QCache class...
EDIT2:
I reload the cache every second, I up the memory used from ~180 to ~225mo.
If I add a clear() before reload the cache, I up to 350mo ?!!
The cache isn't really clear ?!
I don't understand... -
Hi,
What version of Qt are you using ?
On what OS ? -
Hi @hizoka,
I'm not familiar with how to use QPixmapCache, but from your descriptions it looks like there might be problems with its internal implementation.
Your question is about the internal details of Qt, so the best place is at the Interest mailing list. Subscribe there and post your questions -- Qt's engineers are active on that list.
All the best!
-
How big are all your pixmaps combined, compared to your cache size?
There's an interesting description to the function that's called by the 30 sec timer:
This is supposed to cut the cache size down by about 25% in a
minute once the application becomes idle, to let any inserted pixmap
remain in the cache for some time before it becomes a candidate for
cleaning-up, and to not cut down the size of the cache while the
cache is in active use.
When the last detached pixmap has been deleted from the cache, kill the
timer so Qt won't keep the CPU from going into sleep mode. Currently
the timer is not restarted when the pixmap becomes unused, but it does
restart once something else is added (i.e. the cache space is actually needed).So if the total size of your pixmaps is > 75 % of the cache size, the behavior is explainable. Otherwise, it smells like a bug.